diff --git a/.travis.yml b/.travis.yml index 895dbd3..0fe6735 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ language: node_js +sudo: false node_js: - - 0.6 - - 0.8 + - node diff --git a/lib/protocols/drafts.js b/lib/protocols/drafts.js index bb5db72..845f2d3 100644 --- a/lib/protocols/drafts.js +++ b/lib/protocols/drafts.js @@ -10,7 +10,7 @@ */ var Socket = require('../socket') - , EventEmitter = process.EventEmitter + , EventEmitter = require('events') , crypto = require('crypto') , debug = require('debug')('wsio:drafts') @@ -368,4 +368,4 @@ Parser.prototype.error = function (reason) { this.i = 0; this.emit('error', reason); return this; -}; +}; \ No newline at end of file diff --git a/lib/server.js b/lib/server.js index 9f11c4e..a84bfdb 100644 --- a/lib/server.js +++ b/lib/server.js @@ -4,7 +4,7 @@ */ var protocols = require('./protocols') - , EventEmitter = process.EventEmitter + , EventEmitter = require('events') , url = require('url'); /** @@ -123,4 +123,4 @@ Server.prototype.createClient = function (req) { , name = protocols[version] ? version : 'drafts' return new protocols[name](req); -}; +}; \ No newline at end of file diff --git a/lib/socket.js b/lib/socket.js index 98777cd..575f4ef 100644 --- a/lib/socket.js +++ b/lib/socket.js @@ -3,7 +3,7 @@ * Module dependencies. */ -var EventEmitter = process.EventEmitter +var EventEmitter = require('events'); /** * Module exports. @@ -139,4 +139,4 @@ Socket.prototype.destroy = function () { this.onClose(); } return this; -}; +}; \ No newline at end of file diff --git a/lib/websocket.io.js b/lib/websocket.io.js index 739671f..ea98371 100644 --- a/lib/websocket.io.js +++ b/lib/websocket.io.js @@ -59,7 +59,7 @@ exports.listen = function (port, fn, options) { res.end('Not Implemented'); }); - server.listen(port, fn); + server.listen(port || 0, fn); // create ws server var ws = exports.attach(server, options); @@ -85,4 +85,4 @@ exports.attach = function (server, options) { }); return ws; -}; +}; \ No newline at end of file diff --git a/support/server-common.js b/support/server-common.js index b3bf97d..9b212e4 100644 --- a/support/server-common.js +++ b/support/server-common.js @@ -45,9 +45,14 @@ listen = function (options, fn) { */ client = function (addr, path) { - var cl = new Client('ws://' + addr.address + ':' + addr.port + (path || '')); + var address = addr.address; + if (addr.family == 'IPv6') { + address = '[' + address + ']'; + } + + var cl = new Client('ws://' + address + ':' + addr.port + (path || '')); cl.on('error', function (e) { throw e; }); return cl; -} +} \ No newline at end of file diff --git a/test/websocket.io.js b/test/websocket.io.js index 5736c88..dc46050 100644 --- a/test/websocket.io.js +++ b/test/websocket.io.js @@ -3,6 +3,7 @@ * Test dependencies. */ +var should = require('should'); var ws = require('../lib/websocket.io') , http = require('http') @@ -17,12 +18,12 @@ describe('websocket.io', function () { }); it('must expose public constructors', function () { - ws.Socket.should.be.a('function'); - ws.Server.should.be.a('function'); - ws.protocols.drafts.should.be.a('function'); - ws.protocols['7'].should.be.a('function'); - ws.protocols['8'].should.be.a('function'); - ws.protocols['13'].should.be.a('function'); + ws.Socket.should.be.a.Function; + ws.Server.should.be.a.Function; + ws.protocols.drafts.should.be.a.Function; + ws.protocols['7'].should.be.a.Function; + ws.protocols['8'].should.be.a.Function; + ws.protocols['13'].should.be.a.Function; }); it('must connect', function (done) { @@ -84,4 +85,4 @@ describe('websocket.io', function () { }); }); -}); +}); \ No newline at end of file