var _urlHeadAjax; var _authRstData; function auth(serverUrl, account, passwd, serverKey){ _urlHeadAjax = serverUrl + "/rest/"; var jsonObj = {"account":account, "passwd": passwd }; sessionStorage.setItem("serverKey", serverKey); _authRstData = {}; sessionStorage.removeItem("ipocid"); sessionStorage.removeItem("apiKey"); chatRequest("ctcpsEx/auth.json", null, jsonObj, __processAuth); } function __processAuth(data) { if (data.resultCode == 200){ _authRstData = data; sessionStorage.setItem("ipocid", data.ipocid); sessionStorage.setItem("apiKey", data.api_key); account_login(data.wsServerIp, data.ipocid, data.ipocpwd); } else { authCallBack(data); } } function logout(){ sessionStorage.removeItem("serverKey"); sessionStorage.removeItem("ipocid"); sessionStorage.removeItem("apiKey"); account_logout(); } function changePassword(serverUrl, account, orgPasswd, newPasswd, serverKey){ _urlHeadAjax = serverUrl + "/rest/"; var jsonObj = {"account":account, "orgPasswd": orgPasswd, "newPasswd": newPasswd }; chatRequest("ctcpsEx/changePassword.json", null, jsonObj, function (data){ if (typeof changePasswordCallBack === "function"){ changePasswordCallBack(data); } }); } function sesGroupEnter(groupId){ session_channel_enter(groupId); } function sesGroupExit(groupId){ session_channel_exit(groupId); } function sesCallIncomingAccept(groupId){ session_call_incoming_accept(groupId); } function sesCallIncomingReject(groupId){ session_call_incoming_reject(groupId); } function sesCallInitiate(userNumberArr){ session_id_generate(userNumberArr); } function session_id_generate2(userNumberArr){ var jsonObj = {aid: sessionStorage.getItem("ipocid"), aids: userNumberArr}; chatRequest("ctcpsEx/querySessionId.json", "POST", jsonObj, __sesIdGenerateCallBack2); } function __sesIdGenerateCallBack2(data){ if (data.resultCode == 200){ session_call_make(data.sid); } } function __sesIdGenerateCallBack(sessionId){ session_call_make(sessionId); } function sesCallHangup(sessionId){ session_call_bye(sessionId); } function sesLock(sessionId, islock){ session_lock_opt(sessionId, islock); } function sesTalkRequest(sessionId){ session_talk_request(sessionId); } function sesTalkRelease(){ session_talk_release(); } function sesMsgSend(sessionId, msgType, msgContent){ session_message_send(sessionId, msgType, msgContent); } function sesMsgRecPlayStart(code, resId){ session_message_rec_play_start(code, resId); } function sesMsgRecPlayStop(){ session_message_rec_play_stop(); } function accountPresenceSubscribe(sJson){ account_presence_subscribe(1, sJson); } function accountPresenceUnsubscribe(){ account_presence_unsubscribe(); } function sdkVersion(versionFunc){ sdk_version(versionFunc); }