Monday, February 11th, 2008
JSJaC: JavaScript Jabber Client Library
<p>JSJaC 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:
-
-
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) {
-
document.getElementById('iResp').innerHTML += html;
-
document.getElementById('iResp').lastChild.scrollIntoView();
-
return false;
-
}
-
}
-
or handle presence:
-
-
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.
Related Content:











It seems, that everything can be done by JavaScript :)
Prototype window class demo client:
http://jabbermania.blogspot.com/2007/06/jsjabber-educational-client-in.html
Ext.JS version maybe coming soon :) Anyone interested? (I need to wrap jsjac into an ext-style API, it’s nearly done, but I’m curious if anyone needs it)
Hey Adam, I’d love to see it in detail and get to chat with you :)
I tried to reach you on your blog, but it’s kinda difficult since it’s in hungarian.
I hope to hear from you ;)
Hi rameen,
you can reach me at the username aadaam at google’s well-known mail service. (Ajaxian-style spamprotection :)