Permalink
Browse files

adding debugging and better examples.

  • Loading branch information...
1 parent 283e7cc commit b8f5d0b27ea596f50531c8a43ba926989818dcb7 Joachim Kainz committed Apr 29, 2012
Showing with 280 additions and 130 deletions.
  1. +1 −0 .gitignore
  2. +16 −0 Jakefile.js
  3. +5 −5 examples/echo.js
  4. +32 −0 examples/send-msg.js
  5. +20 −0 lib/debug.js
  6. +170 −120 lib/simple-xmpp.js
  7. +5 −5 package.json
  8. +31 −0 tests/debug.test.js
View
@@ -7,4 +7,5 @@ node_modules
*.jar
*.tar
*~
+.idea
*.log
View
@@ -0,0 +1,16 @@
+/* globals desc:false, task: false, complete: fase, jake: false */
+(function (desc, task, complete, jake) {
+ "use strict";
+
+ desc('The default task. Runs tests.');
+ task('default', ['test'], function () {
+ });
+
+ desc('Run tests');
+ task('test', [], function () {
+ jake.exec(["./node_modules/.bin/vows --trace"], function () {
+ console.log('All tests passed.');
+ complete();
+ }, {stdout: true});
+ }, true);
+})(desc, task, complete, jake);
View
@@ -1,19 +1,19 @@
/**
The MIT License
-
+
Copyright (c) 2011 Arunoda Susiripala
-
+
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
-
+
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
-
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -39,7 +39,7 @@ xmpp.on('online', function() {
xmpp.on('chat', function(from, message) {
xmpp.send(from, 'echo: ' + message);
xmpp.probe('arunoda.susiripala@gmail.com', function(state) {
- console.log(state === "online");
+ console.log(state);
});
});
View
@@ -0,0 +1,32 @@
+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],
+ xmpp = simpler({
+ jid:jid,
+ password:password,
+ host:'talk.google.com'
+ }),
+ connection;
+
+xmpp.on('online', function () {
+ console.log('Yes, I\'m connected!');
+ connection.send(to, "this is a message from the send-msg script");
+});
+
+xmpp.on('chat', function (from, message) {
+ console.log("from %s: ", from, message);
+});
+
+xmpp.on('error', function (err) {
+ console.error(err);
+});
+
+connection = xmpp.connect();
View
@@ -0,0 +1,20 @@
+/*jslint node: true, vars: true, indent: 4 */
+(function (module) {
+ "use strict";
+
+ var debug = process.env.NODE_DEBUG && /simpler-xmpp/.test(process.env.NODE_DEBUG),
+ logger = debug ?
+ function () {
+ var args = ['simpler-xmpp:'];
+
+ for (var idx in arguments) {
+ args.push(arguments[idx]);
+ }
+ console.error.apply(this, args);
+ } : function () {
+ };
+
+ logger.debug = debug;
+
+ return module.exports = logger;
+})(module);
Oops, something went wrong.

0 comments on commit b8f5d0b

Please sign in to comment.