From 3f34f77fcd9e8f767c21eca9275f838be5dc55b3 Mon Sep 17 00:00:00 2001 From: Bryan Ashby Date: Sun, 8 Jul 2018 11:23:56 -0600 Subject: [PATCH] Implement fake pipe() for WebSocket (doors/etc.) --- core/servers/login/websocket.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/core/servers/login/websocket.js b/core/servers/login/websocket.js index fa7d97a3..3fc16343 100644 --- a/core/servers/login/websocket.js +++ b/core/servers/login/websocket.js @@ -31,7 +31,11 @@ function WebSocketClient(ws, req, serverType) { const self = this; this.dataHandler = function(data) { - self.socketBridge.emit('data', data); + if(self.pipedDest) { + self.pipedDest.write(data); + } else { + self.socketBridge.emit('data', data); + } }; // @@ -54,9 +58,14 @@ function WebSocketClient(ws, req, serverType) { return this.ws.send(data, { binary : true }, cb); } - // we need to fake some streaming work + pipe(dest) { + Log.trace('WebSocket SocketBridge pipe()'); + self.pipedDest = dest; + } + unpipe() { Log.trace('WebSocket SocketBridge unpipe()'); + self.pipedDest = null; } resume() {