Set readyState to OPEN as soon as possible.
This commit is contained in:
@@ -46,9 +46,15 @@ var WebSocket = function(request, socket, head, supportedProtos, options) {
|
||||
var Parser = getParser(request);
|
||||
this._parser = new Parser(this, {protocols: supportedProtos});
|
||||
|
||||
var self = this;
|
||||
this._sendBuffer = [];
|
||||
process.nextTick(function() { self._open() });
|
||||
|
||||
var handshake = this._parser.handshakeResponse(head);
|
||||
try { this._stream.write(handshake, 'binary') } catch (e) {}
|
||||
|
||||
if (this._parser.isOpen()) this.readyState = API.OPEN;
|
||||
|
||||
this.protocol = this._parser.protocol || '';
|
||||
this.version = this._parser.getVersion();
|
||||
|
||||
@@ -62,10 +68,6 @@ var WebSocket = function(request, socket, head, supportedProtos, options) {
|
||||
self.ping(id);
|
||||
}, this._ping * 1000);
|
||||
|
||||
var self = this;
|
||||
this._sendBuffer = [];
|
||||
process.nextTick(function() { self._open() });
|
||||
|
||||
this._stream.addListener('data', function(data) {
|
||||
var response = self._parser.parse(data);
|
||||
if (!response) return;
|
||||
|
||||
Reference in New Issue
Block a user