Permalink
Browse files

adding support for rooms.

  • Loading branch information...
Joachim Kainz
Joachim Kainz committed May 4, 2012
1 parent c8e43d0 commit 910a2f000782262bb830ffa501683fe3f2b0f0cc
Showing with 201 additions and 105 deletions.
  1. +51 −0 examples/room.js
  2. +48 −44 examples/send-msg.js
  3. +13 −5 lib/debug.js
  4. +89 −56 lib/simple-xmpp.js
View
@@ -0,0 +1,51 @@
(function (process, console) {
"use strict";
process.on('uncaughtException', function (err) {
console.error(err.stack || err);
});
var util = require("util");
if (process.argv.length < 5) {
console.log("please pass jid, password, and the muc jid as command line params");
process.exit(1);
}
var simpler = require('../index'),
jid = process.argv[2],
password = process.argv[3],
to = process.argv[4],
client = simpler({
jid:jid,
password:password,
host:'talk.google.com'
}),
connection;
client.on('online', function () {
console.log('online!');
});
client.on('stanza', function (stanza) {
console.log("stanza: %j", stanza);
});
client.on('chat', function (from, message) {
console.log("from %s: ", from, message);
});
client.on('roster', function (roster) {
console.log("roster", roster);
});
client.on('presence', function (from, presence, presences) {
console.log("presence", from, presence);
});
client.on('error', function (err) {
console.error("error: %j", err);
});
client.discoverRoom(to);
})(process, console);
View
@@ -1,44 +1,48 @@
process.on('uncaughtException', function(err) {
console.error(err.stack || err);
});
var util = require("util");
if (process.argv.length < 5) {
console.log("please pass jid, password, and the destination address as command line params");
process.exit(1);
}
var simpler = require('../index'),
jid = process.argv[2],
password = process.argv[3],
to = process.argv[4],
client = simpler({
jid:jid,
password:password,
host:'talk.google.com'
}),
connection;
client.on('online', function () {
console.log('online!');
});
client.on('chat', function (from, message) {
console.log("from %s: ", from, message);
});
client.on('roster', function (roster) {
console.log("roster", roster);
});
client.on('presence', function (from, presence, presences) {
console.log("presence", from, presence);
});
client.on('error', function (err) {
console.error(err);
});
client.send(to, "this is a message from the send-msg script at " + new Date());
client.addBuddy(to);
(function (process, console) {
"use strict";
process.on('uncaughtException', function (err) {
console.error(err.stack || err);
});
var util = require("util");
if (process.argv.length < 5) {
console.log("please pass jid, password, and the destination address as command line params");
process.exit(1);
}
var simpler = require('../index'),
jid = process.argv[2],
password = process.argv[3],
to = process.argv[4],
client = simpler({
jid:jid,
password:password,
host:'talk.google.com'
}),
connection;
client.on('online', function () {
console.log('online!');
});
client.on('chat', function (from, message) {
console.log("from %s: ", from, message);
});
client.on('roster', function (roster) {
console.log("roster", roster);
});
client.on('presence', function (from, presence, presences) {
console.log("presence", from, presence);
});
client.on('error', function (err) {
console.error(err);
});
client.addBuddy(to);
client.send(to, "this is a message from the send-msg script at " + new Date());
})(process, console);
View
@@ -2,15 +2,23 @@
(function (module) {
"use strict";
function formatMessage() {
var args = Array.prototype.slice.call(arguments),
first = args.shift();
args.unshift(new Date());
args.unshift('[simpler-xmpp: %s] ' + first);
return util.format.apply(this, args);
}
var debug = process.env.NODE_DEBUG && /simpler-xmpp/.test(process.env.NODE_DEBUG),
util = require('util'),
logger = debug ?
function () {
var args = ['simpler-xmpp:'];
var message = formatMessage.apply(this, arguments);
for (var idx in arguments) {
args.push(arguments[idx]);
}
console.error.apply(this, args);
console.error(message);
} : function () {
};
Oops, something went wrong.

0 comments on commit 910a2f0

Please sign in to comment.