//=================================================================
|
// API说明
|
//
|
// Function:
|
//
|
// - account_event_set_loginout(cbLogin, cbLogout, cbHeartbeat):设置全局本机用户登录登出回调
|
// - account_event_set_presence(cbPresence):设置全局用户状态变化回调函数
|
//
|
// - account_login(serverAddr, userId, userPass):本机用户登录系统
|
// - account_logout():本机用户登出系统
|
//
|
// Event:
|
//
|
// - cbUserLogin(result); 用户登录状态返回
|
// - cbUserLogout(); 用户登出状态返回
|
// - cbUserHeartbeat(result); 用户心跳状态返回
|
// - cbUserPresence(json); 用户在线状态
|
//
|
//=================================================================
|
|
|
var cbUserPresence = null;
|
var cbUserLogin = null;
|
var cbUserLogout = null;
|
var cbUserHeartbeat = null;
|
|
|
/******************************* FUNC ********************************/
|
|
function account_event_set_loginout(cbLogin, cbLogout, cbHeartbeat) {
|
cbUserLogin = cbLogin;
|
cbUserLogout = cbLogout;
|
cbUserHeartbeat = cbHeartbeat;
|
}
|
|
function account_event_set_presence(cbPresence) {
|
cbUserPresence = cbPresence;
|
}
|
|
function account_login(serverAddr, userId, userPass) {
|
doLogin(serverAddr, userId, userPass);
|
}
|
|
function account_logout() {
|
doLoginOut();
|
}
|
|
function account_presence_subscribe(isCustom, json) {
|
doPresenceSubscribe(isCustom, json);
|
}
|
|
function account_presence_unsubscribe() {
|
doPresenceUnsubscribe();
|
}
|
|
/******************************* EVENT ********************************/
|
|
function onLogin(result, secret) {
|
if (cbUserLogin != null)
|
cbUserLogin(result);
|
}
|
|
function onLogout(result) {
|
if (cbUserLogout != null)
|
cbUserLogout();
|
}
|
|
function onHeartbeat(result) {
|
if (cbUserHeartbeat != null)
|
cbUserHeartbeat(result);
|
}
|
|
// user presence
|
function onContactPresence(json) {
|
if (cbUserPresence != null && json != null)
|
cbUserPresence(json.sessionmember);
|
}
|