Sunday, April 3, 2011

Socket.io with XMPP

[cc lang="javascript"]var server = require("http").createServer();
var socket = require("socket.io").listen(server);
var xmpp = require("node-xmpp");
socket.on("connection", function(connection) {
var client = new xmpp.Client({jid: "charlvn@jabber.co.za", password: ""});
client.on("online", function() {
client.send(new xmpp.Element("presence", {type: "chat"}));
connection.on("message", function(message) {
client.send(new xmpp.Element("message", {to: "charlvn@charlvn.com", type: "chat"}).c("body").t(message));
});
connection.on("disconnect", function() {
client.end();
});
});
client.on("stanza", function(stanza) {
if (stanza.is("message")) {
var b = stanza.getChildren("body");
if (b[0]) connection.send(b[0].getText());
}
});
});
server.listen(8080);[/cc]

[cc lang="html"]

XMPP



    [/cc]

    6 comments:

    1. Is this example actually works? i want to try it...

      ReplyDelete
    2. acquire the most recent promotion codes from the protein works
      the protein works discount coupons

      ReplyDelete
    3. Thanks for any other informative web site. The place else may I am getting that kind of info written in such a perfect manner? I have a project that I am just now operating on, and I've been at the glance out for such info.

      ReplyDelete
    4. You actually make it seem really easy with your presentation however I in finding this topic
      to be actually something which I think I might never understand.
      It seems too complex and very huge for me. I'm taking a look ahead on your subsequent submit, I will attempt to get the cling of it!

      ReplyDelete
    5. Hi! This post couldn't be written any better! Reading through this post reminds me of my previous room mate! He always kept chatting about this. I will forward this page to him. Pretty sure he will have a good read. Thank you for sharing!

      ReplyDelete