diff --git a/example/server.js b/example/server.js index bfd81973b2..0796f9cf67 100644 --- a/example/server.js +++ b/example/server.js @@ -6,7 +6,7 @@ var http = require('http') , url = require('url') , fs = require('fs') , io = require('../') - , sys = require('sys') + , sys = require(process.binding('natives').util ? 'util' : 'sys')) , server; server = http.createServer(function(req, res){ @@ -60,4 +60,4 @@ io.on('connection', function(client){ client.on('disconnect', function(){ client.broadcast({ announcement: client.sessionId + ' disconnected' }); }); -}); \ No newline at end of file +}); diff --git a/lib/socket.io/client.js b/lib/socket.io/client.js index e0a9d558fe..afebaf9a44 100644 --- a/lib/socket.io/client.js +++ b/lib/socket.io/client.js @@ -4,7 +4,8 @@ var urlparse = require('url').parse , options = require('./utils').options , encode = require('./utils').encode , decode = require('./utils').decode - , merge = require('./utils').merge; + , merge = require('./utils').merge + , util = require(process.binding('natives').util ? 'util' : 'sys'); var Client = module.exports = function(listener, req, res, options, head){ process.EventEmitter.call(this); @@ -22,7 +23,7 @@ var Client = module.exports = function(listener, req, res, options, head){ this._onConnect(req, res); }; -require('sys').inherits(Client, process.EventEmitter); +util.inherits(Client, process.EventEmitter); Client.prototype.send = function(message){ if (!this._open || !(this.connection.readyState === 'open' || this.connection.readyState === 'writeOnly')){ diff --git a/lib/socket.io/listener.js b/lib/socket.io/listener.js index 2a40b9aa31..4d042d64c9 100644 --- a/lib/socket.io/listener.js +++ b/lib/socket.io/listener.js @@ -1,5 +1,5 @@ var url = require('url') - , sys = require('sys') + , util = require(process.binding('natives').util ? 'util' : 'sys') , fs = require('fs') , options = require('./utils').options , Client = require('./client') @@ -23,7 +23,7 @@ var Listener = module.exports = function(server, options){ flashPolicyServer: true, transports: ['websocket', 'flashsocket', 'htmlfile', 'xhr-multipart', 'xhr-polling', 'jsonp-polling'], transportOptions: {}, - log: sys.log + log: util.log }, options); if (!this.options.log) this.options.log = function(){}; @@ -55,7 +55,7 @@ var Listener = module.exports = function(server, options){ this.options.log('socket.io ready - accepting connections'); }; -sys.inherits(Listener, process.EventEmitter); +util.inherits(Listener, process.EventEmitter); for (var i in options) Listener.prototype[i] = options[i]; Listener.prototype.broadcast = function(message, except){ @@ -166,4 +166,4 @@ Listener.prototype._onClientDisconnect = function(client){ Listener.prototype._onConnection = function(transport, req, res, httpUpgrade, head){ this.options.log('Initializing client with transport "'+ transport +'"'); new transports[transport](this, req, res, this.options.transportOptions[transport], head); -}; \ No newline at end of file +}; diff --git a/lib/socket.io/transports/flashsocket.js b/lib/socket.io/transports/flashsocket.js index 75515ea6b4..4989354ef1 100644 --- a/lib/socket.io/transports/flashsocket.js +++ b/lib/socket.io/transports/flashsocket.js @@ -1,4 +1,5 @@ var net = require('net') + , util = require(process.binding('natives').util ? 'util' : 'sys') , WebSocket = require('./websocket') , listeners = [] , netserver; @@ -7,7 +8,7 @@ var Flashsocket = module.exports = function(){ WebSocket.apply(this, arguments); }; -require('sys').inherits(Flashsocket, WebSocket); +util.inherits(Flashsocket, WebSocket); Flashsocket.httpUpgrade = true; @@ -82,4 +83,4 @@ function policy(listeners) { xml += '\n'; return xml; -}; \ No newline at end of file +}; diff --git a/lib/socket.io/transports/htmlfile.js b/lib/socket.io/transports/htmlfile.js index 9812c101b7..9c4b91d1e3 100644 --- a/lib/socket.io/transports/htmlfile.js +++ b/lib/socket.io/transports/htmlfile.js @@ -1,11 +1,12 @@ var Client = require('../client') + , util = require(process.binding('natives').util ? 'util' : 'sys') , qs = require('querystring'); var HTMLFile = module.exports = function(){ Client.apply(this, arguments); }; -require('sys').inherits(HTMLFile, Client); +util.inherits(HTMLFile, Client); HTMLFile.prototype._onConnect = function(req, res){ var self = this, body = ''; @@ -43,4 +44,4 @@ HTMLFile.prototype._onConnect = function(req, res){ HTMLFile.prototype._write = function(message){ if (this._open) this.response.write(''); //json for escaping -}; \ No newline at end of file +}; diff --git a/lib/socket.io/transports/jsonp-polling.js b/lib/socket.io/transports/jsonp-polling.js index 502a9613a0..82ff6349c7 100644 --- a/lib/socket.io/transports/jsonp-polling.js +++ b/lib/socket.io/transports/jsonp-polling.js @@ -1,10 +1,11 @@ -var XHRPolling = require('./xhr-polling'); +var XHRPolling = require('./xhr-polling') + , util = require(process.binding('natives').util ? 'util' : 'sys'); JSONPPolling = module.exports = function(){ XHRPolling.apply(this, arguments); }; -require('sys').inherits(JSONPPolling, XHRPolling); +util.inherits(JSONPPolling, XHRPolling); JSONPPolling.prototype.getOptions = function(){ return { @@ -31,4 +32,4 @@ JSONPPolling.prototype._write = function(message){ this.response.end(); this._onClose(); } -}; \ No newline at end of file +}; diff --git a/lib/socket.io/transports/websocket.js b/lib/socket.io/transports/websocket.js index d3798444c2..b950d15803 100644 --- a/lib/socket.io/transports/websocket.js +++ b/lib/socket.io/transports/websocket.js @@ -1,13 +1,14 @@ var Client = require('../client') , Stream = require('net').Stream , url = require('url') + , util = require(process.binding('natives').util ? 'util' : 'sys') , crypto = require('crypto'); WebSocket = module.exports = function(){ Client.apply(this, arguments); }; -require('sys').inherits(WebSocket, Client); +util.inherits(WebSocket, Client); WebSocket.prototype._onConnect = function(req, socket){ var self = this @@ -133,4 +134,4 @@ WebSocket.prototype._write = function(message){ } }; -WebSocket.httpUpgrade = true; \ No newline at end of file +WebSocket.httpUpgrade = true; diff --git a/lib/socket.io/transports/xhr-multipart.js b/lib/socket.io/transports/xhr-multipart.js index 1c2e9c7253..e080ea3d7f 100644 --- a/lib/socket.io/transports/xhr-multipart.js +++ b/lib/socket.io/transports/xhr-multipart.js @@ -1,11 +1,12 @@ var Client = require('../client') + , util = require(process.binding('natives').util ? 'util' : 'sys') , qs = require('querystring'); var Multipart = module.exports = function(){ Client.apply(this, arguments); }; -require('sys').inherits(Multipart, Client); +util.inherits(Multipart, Client); Multipart.prototype._onConnect = function(req, res){ var self = this, body = '', headers = {}; @@ -61,4 +62,4 @@ Multipart.prototype._write = function(message){ this.response.write(message + "\n"); this.response.write("--socketio\n"); } -}; \ No newline at end of file +}; diff --git a/lib/socket.io/transports/xhr-polling.js b/lib/socket.io/transports/xhr-polling.js index e85392c5b4..23b121e7e8 100644 --- a/lib/socket.io/transports/xhr-polling.js +++ b/lib/socket.io/transports/xhr-polling.js @@ -1,11 +1,12 @@ var Client = require('../client') + , util = require(process.binding('natives').util ? 'util' : 'sys') , qs = require('querystring'); var Polling = module.exports = function(){ Client.apply(this, arguments); }; -require('sys').inherits(Polling, Client); +util.inherits(Polling, Client); Polling.prototype.getOptions = function(){ return { @@ -75,4 +76,4 @@ Polling.prototype._write = function(message){ this.response.end(); this._onClose(); } -}; \ No newline at end of file +}; diff --git a/package.json b/package.json index 836b7407d1..d072c31fa0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name" : "socket.io" , "description" : "The cross-browser WebSocket" -, "version" : "0.6.1" +, "version" : "0.6.3" , "author" : "LearnBoost" , "licenses" : [ { "type" : "MIT"