Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

switchProtocols without upgradeHead.

  • Loading branch information...
commit 0ca0d2018a1f17da31399b10c2d2231435a87122 1 parent 54630ee
@stephank authored
Showing with 6 additions and 10 deletions.
  1. +6 −10 lib/faye/websocket.js
View
16 lib/faye/websocket.js
@@ -52,27 +52,23 @@ var WebSocket = function(request, response, supportedProtos, options) {
this.protocol = self._parser.protocol || '';
this.version = self._parser.getVersion();
- response.switchProtocols(function(socket, head) {
+ response.switchProtocols(function(socket) {
self._stream = socket;
self._stream.setTimeout(0);
self._stream.setNoDelay(true);
- var dataListener = function(data) {
+ self._stream.addListener('data', function(data) {
var reply = self._parser.parse(data);
if (!reply) return;
try { self._stream.write(reply, 'binary') } catch (e) {}
self._open();
- };
- self._stream.addListener('data', dataListener);
-
- var closeListener = function() {
- self.close(1006, '', false);
- };
+ });
['close', 'end', 'error'].forEach(function(event) {
- self._stream.addListener(event, closeListener);
+ self._stream.addListener(event, function() {
+ self.close(1006, '', false);
+ });
});
- if (head.length !== 0) dataListener(head);
if (self._parser.isOpen()) self.readyState = API.OPEN;
process.nextTick(function() { self._open() });
Please sign in to comment.
Something went wrong with that request. Please try again.