Skip to content

Commit b57b00b

Browse files
committed
Added missing Parser#error method
Restored previous sessionid generation mechanism temporarily
1 parent 9d19ae6 commit b57b00b

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/socket.io/client.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ Client.prototype._queue = function(type, data){
190190
};
191191

192192
Client.prototype._generateSessionId = function(){
193-
this.sessionId = ++this.listener._clientCount; // REFACTORME
193+
this.sessionId = Math.random().toString().substr(2); // REFACTORME
194194
return this;
195195
};
196196

lib/socket.io/transports/websocket.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ WebSocket.prototype._onConnect = function(req, socket){
2121

2222
this.parser = new Parser();
2323
this.parser.on('data', self._onData.bind(this));
24+
this.parser.on('error', self._onClose.bind(this));
2425

2526
Client.prototype._onConnect.call(this, req);
2627

@@ -154,3 +155,10 @@ Parser.prototype.parse = function(){
154155
}
155156
}
156157
};
158+
159+
Parser.prototype.error = function(reason){
160+
this.buffer = '';
161+
this.i = 0;
162+
this.emit('error', reason);
163+
return this;
164+
};

0 commit comments

Comments
 (0)