remote.jsjac.chat.sendMessage(text, receiver); 这个是发送远程消息的方法,参数1是消息内容、参数2是消息的接收者
如果你有看到这篇文章http://www.cnblogs.com/hoojo/archive/2012/06/18/2553886.html 它是一个单纯的WebIM本地的聊天界面。
3、远程聊天JavaScript核心代码,它是和jsjac库关联的。
remote.jsjac.chat-2.0.js
/**
* IM chat jsjac remote message
* @author: hoojo
* @email: hoojo_@126.com
* @blog http://hoojo.cnblogs.com & http://blog.csdn.net/IBM_hoojo
* @createDate: 2012-5-24
* @version 2.0
* @requires jQuery v1.2.3 or later
* Copyright (c) 2012 M. hoo
**/
var remote = {
debug: “info, error”,
chat: “body”,
receiver: “#to”, // 接受者jquery expression
console: {
errorEL: function () {
if ($(remote.chat).get(0)) {
return $(remote.chat).find(“#error”);
} else {
return $(“body”).find(“#error”);
}
},
infoEL: function () {
if ($(remote.chat).get(0)) {
return $(remote.chat).find(“#info”);
} else {
return $(“body”).find(“#info”);
}
},
// debug info
info: function (html) {
if (~remote.debug.indexOf(“info”)) {
remote.console.infoEL().append(html);
remote.console.infoEL().get(0).lastChild.scrollIntoView();
}
},
// debug error
error: function (html) {
if (~remote.debug.indexOf(“error”)) {
remote.console.errorEL().append(html);
}
},
// clear info/debug console
clear: function (s) {
if (“debug” == s) {
remote.console.errorEL().html(“”);
} else {
remote.console.infoEL().html(“”);
}
}
},
userAddress: function (user) {
if (user) {
if (!~user.indexOf(“@”)) {
user += “@” + remote.jsjac.domain;// + “/” + remote.jsjac.resource;
} else if (~user.indexOf(“/”)) {
user = user.substr(0, user.indexOf(“/”));
}
}
return user;
},
jsjac: {
httpbase: window.contextPath + “/JHB/”, //请求后台http-bind服务器url
domain: window[“serverDomin”], //”192.168.5.231″, // 192.168.5.231 当前有效域名
username: “”,
pass: “”,
timerval: 2000, // 设置请求超时
resource: “WebIM”, // 链接资源标识
register: true // 是否注册
}
};
remote.jsjac.chat = {
writeReceiveMessage: function () {
},
setState: function () {
var onlineStatus = new Object();
onlineStatus[“available”] = “在线”;
onlineStatus[“chat”] = “欢迎聊天”;
onlineStatus[“away”] = “离开”;
onlineStatus[“xa”] = “不可用”;
onlineStatus[“dnd”] = “请勿打扰”;










