JSJaC: JavaScript Jabber Client Library
Date : 2008 02 11 Category : Tech & DevelopmentJSJaC is a JavaScript Jabber Client Library that was built "to ease implementation of web based jabber clients. For communication with a jabber server it needs to support either HTTP Polling or HTTP Binding."
To use the library you can check out examples to see how you can do things like send a message:
PLAIN TEXT JAVASCRIPT:function sendMsg(aForm) {
if (aForm.msg.value == '' || aForm.sendTo.value == '')
return false;
if (aForm.sendTo.value.indexOf('@') == -1)
aForm.sendTo.value += '@' + con.domain;
try {
var aMsg = new JSJaCMessage();
aMsg.setTo(new JSJaCJID(aForm.sendTo.value));
aMsg.setBody(aForm.msg.value);
con.send(aMsg);
aForm.msg.value = '';
return false;
} catch (e) {
html = "<div class='msg error''>Error: "+e.message+"</div>";
document.getElementById('iResp').innerHTML += html;
document.getElementById('iResp').lastChild.scrollIntoView();
return false;
}
}
or handle presence:
PLAIN TEXT JAVASCRIPT:function handlePresence(aJSJaCPacket) {
var html = '<div class="msg">';
if (!aJSJaCPacket.getType() && !aJSJaCPacket.getShow())
html += '<b>'+aJSJaCPacket.getFromJID()+' has become available.</b>';
else {
html += '<b>'+aJSJaCPacket.getFromJID()+' has set his presence to ';
if (aJSJaCPacket.getType())
html += aJSJaCPacket.getType() + '.</b>';
else
html += aJSJaCPacket.getShow() + '.';
if (aJSJaCPacket.getStatus())
html += ' ('+aJSJaCPacket.getStatus().htmlEnc()+')';
}
html += '</div>';
document.getElementById('iResp').innerHTML += html;
document.getElementById('iResp').lastChild.scrollIntoView();
}
Since Jabber (XMPP) is taking over the world, it may be a nice tool in the toolbox.