Permalink
Browse files

Started cleanup

  • Loading branch information...
1 parent 6074795 commit 9e467381f34fa39e8321b26f837e290b57bb9a9f @rauchg rauchg committed Jan 25, 2012
View
@@ -51,10 +51,10 @@ app.listen(3000, function () {
* Socket.IO server (single process only)
*/
-var io = sio.listen(app)
+var io = sio(app)
, nicknames = {};
-io.sockets.on('connection', function (socket) {
+io.on('connection', function (socket) {
socket.on('user message', function (msg) {
socket.broadcast.emit('user message', socket.nickname, msg);
});
@@ -66,7 +66,7 @@ io.sockets.on('connection', function (socket) {
fn(false);
nicknames[nick] = socket.nickname = nick;
socket.broadcast.emit('announcement', nick + ' connected');
- io.sockets.emit('nicknames', nicknames);
+ io.emit('nicknames', nicknames);
}
});
@@ -52,7 +52,7 @@ app.listen(3000, function () {
* Socket.IO server
*/
-var io = sio.listen(app)
+var io = sio(app)
/**
* Connect to IRC.
@@ -64,11 +64,11 @@ client.on('001', function () {
this.send('JOIN', '#node.js');
});
client.on('PART', function (prefix) {
- io.sockets.emit('announcement', irc.user(prefix) + ' left the channel');
+ io.emit('announcement', irc.user(prefix) + ' left the channel');
});
client.on('JOIN', function (prefix) {
- io.sockets.emit('announcement', irc.user(prefix) + ' joined the channel');
+ io.emit('announcement', irc.user(prefix) + ' joined the channel');
});
client.on('PRIVMSG', function (prefix, channel, text) {
- io.sockets.emit('irc message', irc.user(prefix), text);
+ io.emit('irc message', irc.user(prefix), text);
});
View
@@ -1,97 +0,0 @@
-
-/*!
- * socket.io-node
- * Copyright(c) 2011 LearnBoost <dev@learnboost.com>
- * MIT Licensed
- */
-
-/**
- * Module dependencies.
- */
-
-var util = require('./util')
- , toArray = util.toArray;
-
-/**
- * Log levels.
- */
-
-var levels = [
- 'error'
- , 'warn'
- , 'info'
- , 'debug'
-];
-
-/**
- * Colors for log levels.
- */
-
-var colors = [
- 31
- , 33
- , 36
- , 90
-];
-
-/**
- * Pads the nice output to the longest log level.
- */
-
-function pad (str) {
- var max = 0;
-
- for (var i = 0, l = levels.length; i < l; i++)
- max = Math.max(max, levels[i].length);
-
- if (str.length < max)
- return str + new Array(max - str.length + 1).join(' ');
-
- return str;
-};
-
-/**
- * Logger (console).
- *
- * @api public
- */
-
-var Logger = module.exports = function (opts) {
- opts = opts || {}
- this.colors = false !== opts.colors;
- this.level = 3;
- this.enabled = true;
-};
-
-/**
- * Log method.
- *
- * @api public
- */
-
-Logger.prototype.log = function (type) {
- var index = levels.indexOf(type);
-
- if (index > this.level || !this.enabled)
- return this;
-
- console.log.apply(
- console
- , [this.colors
- ? ' \033[' + colors[index] + 'm' + pad(type) + ' -\033[39m'
- : type + ':'
- ].concat(toArray(arguments).slice(1))
- );
-
- return this;
-};
-
-/**
- * Generate methods.
- */
-
-levels.forEach(function (name) {
- Logger.prototype[name] = function () {
- this.log.apply(this, [name].concat(toArray(arguments)));
- };
-});
Oops, something went wrong.

0 comments on commit 9e46738

Please sign in to comment.