From 7e88903bcc07de73d172f92610139d435e369721 Mon Sep 17 00:00:00 2001 From: SteveSandersonMS Date: Tue, 27 Sep 2016 10:28:50 +0100 Subject: [PATCH] Fix Node event chaining in VirtualConnectionServer to work with latest NPM libraries. Fixes #331. --- .../VirtualConnectionServer.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/Microsoft.AspNetCore.NodeServices/TypeScript/VirtualConnections/VirtualConnectionServer.ts b/src/Microsoft.AspNetCore.NodeServices/TypeScript/VirtualConnections/VirtualConnectionServer.ts index 7381060..76b833d 100644 --- a/src/Microsoft.AspNetCore.NodeServices/TypeScript/VirtualConnections/VirtualConnectionServer.ts +++ b/src/Microsoft.AspNetCore.NodeServices/TypeScript/VirtualConnections/VirtualConnectionServer.ts @@ -105,15 +105,16 @@ class VirtualConnectionsCollection { } }; - const newVirtualConnection = new VirtualConnection(beginWriteCallback) - .on('end', () => { - // The virtual connection was closed remotely. Clean up locally. - this._onVirtualConnectionWasClosed(header.connectionIdString); - }).on('finish', () => { - // The virtual connection was closed locally. Clean up locally, and notify the remote that we're done. - this._onVirtualConnectionWasClosed(header.connectionIdString); - this._sendFrame(header.connectionIdBinary, new Buffer(0)); - }); + const newVirtualConnection = new VirtualConnection(beginWriteCallback); + newVirtualConnection.on('end', () => { + // The virtual connection was closed remotely. Clean up locally. + this._onVirtualConnectionWasClosed(header.connectionIdString); + }); + newVirtualConnection.on('finish', () => { + // The virtual connection was closed locally. Clean up locally, and notify the remote that we're done. + this._onVirtualConnectionWasClosed(header.connectionIdString); + this._sendFrame(header.connectionIdBinary, new Buffer(0)); + }); this._virtualConnections[header.connectionIdString] = newVirtualConnection; this._onVirtualConnectionCallback(newVirtualConnection);