Skip to content

Commit

Permalink
0.3 compatibility (thanks Arnout)
Browse files Browse the repository at this point in the history
  • Loading branch information
rauchg committed Dec 23, 2010
1 parent d298113 commit c958a12
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 22 deletions.
4 changes: 2 additions & 2 deletions example/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down Expand Up @@ -60,4 +60,4 @@ io.on('connection', function(client){
client.on('disconnect', function(){
client.broadcast({ announcement: client.sessionId + ' disconnected' });
});
});
});
5 changes: 3 additions & 2 deletions lib/socket.io/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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')){
Expand Down
8 changes: 4 additions & 4 deletions lib/socket.io/listener.js
Original file line number Diff line number Diff line change
@@ -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')
Expand All @@ -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(){};
Expand Down Expand Up @@ -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){
Expand Down Expand Up @@ -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);
};
};
5 changes: 3 additions & 2 deletions lib/socket.io/transports/flashsocket.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var net = require('net')
, util = require(process.binding('natives').util ? 'util' : 'sys')
, WebSocket = require('./websocket')
, listeners = []
, netserver;
Expand All @@ -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;

Expand Down Expand Up @@ -82,4 +83,4 @@ function policy(listeners) {

xml += '</cross-domain-policy>\n';
return xml;
};
};
5 changes: 3 additions & 2 deletions lib/socket.io/transports/htmlfile.js
Original file line number Diff line number Diff line change
@@ -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 = '';
Expand Down Expand Up @@ -43,4 +44,4 @@ HTMLFile.prototype._onConnect = function(req, res){
HTMLFile.prototype._write = function(message){
if (this._open)
this.response.write('<script>parent.s._('+ JSON.stringify(message) +', document);</script>'); //json for escaping
};
};
7 changes: 4 additions & 3 deletions lib/socket.io/transports/jsonp-polling.js
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -31,4 +32,4 @@ JSONPPolling.prototype._write = function(message){
this.response.end();
this._onClose();
}
};
};
5 changes: 3 additions & 2 deletions lib/socket.io/transports/websocket.js
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -133,4 +134,4 @@ WebSocket.prototype._write = function(message){
}
};

WebSocket.httpUpgrade = true;
WebSocket.httpUpgrade = true;
5 changes: 3 additions & 2 deletions lib/socket.io/transports/xhr-multipart.js
Original file line number Diff line number Diff line change
@@ -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 = {};
Expand Down Expand Up @@ -61,4 +62,4 @@ Multipart.prototype._write = function(message){
this.response.write(message + "\n");
this.response.write("--socketio\n");
}
};
};
5 changes: 3 additions & 2 deletions lib/socket.io/transports/xhr-polling.js
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -75,4 +76,4 @@ Polling.prototype._write = function(message){
this.response.end();
this._onClose();
}
};
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

1 comment on commit c958a12

@polidore
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fix isn't in NPM yet.

Please sign in to comment.