JavaScript/jQuery、HTML、CSS 构建 Web IM 远程及时聊天通信程序

2020-05-22 16:09:00易采站长站整理

onlineStatus[“invisible”] = “隐身”;
onlineStatus[“unavailable”] = “离线”;
remote.jsjac.chat.state = onlineStatus;
return onlineStatus;
},
state: null,
init: function () {
// Debugger plugin
if (typeof (Debugger) == “function”) {
remote.dbger = new Debugger(2, remote.jsjac.resource);
remote.dbger.start();
} else {
// if you’re using firebug or safari, use this for debugging
// oDbg = new JSJaCConsoleLogger(2);
// comment in above and remove comments below if you don’t need debugging
remote.dbger = function () {
};
remote.dbger.log = function () {
};
}
try {
// try to resume a session
if (JSJaCCookie.read(“btype”).getValue() == “binding”) {
remote.connection = new JSJaCHttpBindingConnection({ “oDbg”: remote.dbger});
rdbgerjac.chat.setupEvent(remote.connection);
if (remote.connection.resume()) {
remote.console.clear(“debug”);
}
}
} catch (e) {
remote.console.errorEL().html(e.name + “:” + e.message);
} // reading cookie failed – never mind
remote.jsjac.chat.setState();
},
login: function (loginForm) {
remote.console.clear(“debug”); // reset
try {
// 链接参数
var connectionConfig = remote.jsjac;
// Debugger console
if (typeof (oDbg) != “undefined”) {
connectionConfig.oDbg = oDbg;
}
var connection = new JSJaCHttpBindingConnection(connectionConfig);
remote.connection = connection;
// 安装(注册)Connection事件模型
remote.jsjac.chat.setupEvent(connection);
// setup args for connect method
if (loginForm) {
//connectionConfig = new Object();
//connectionConfig.domain = loginForm.domain.value;
connectionConfig.username = loginForm.userName.value;
connectionConfig.pass = loginForm.password.value;
connectionConfig.register = loginForm.register.checked;
}
// 连接服务器
connection.connect(connectionConfig);
//remote.jsjac.chat.changeStatus(“available”, “online”, 1, “chat”);
} catch (e) {
remote.console.errorEL().html(e.toString());
} finally {
return false;
}
},
// 改变用户状态
changeStatus: function (type, status, priority, show) {
type = type || “unavailable”;
status = status || “online”;
priority = priority || “1”;
show = show || “chat”;
var presence = new JSJaCPresence();
presence.setType(type); // unavailable invisible
if (remote.connection) {
//remote.connection.send(presence);
}
//presence = new JSJaCPresence();
presence.setStatus(status); // online
presence.setPriority(priority); // 1
presence.setShow(show); // chat
if (remote.connection) {
remote.connection.send(presence);
}
},
// 为Connection注册事件
setupEvent: function (con) {