proxyinterceptor: handle SocketDisconnectEvent

This commit is contained in:
calzoneman 2016-03-07 20:25:32 -08:00
parent d913f02657
commit a96b85fa5b
1 changed files with 14 additions and 0 deletions

View File

@ -24,6 +24,7 @@ export default class ProxyInterceptor {
socket.on('close', this.onFrontendDisconnect.bind(this, socket));
socket.on('SocketConnectEvent', this.onSocketConnect.bind(this, socket));
socket.on('SocketFrameEvent', this.onSocketFrame.bind(this, socket));
socket.on('SocketDisconnectEvent', this.onSocketDisconnect.bind(this, socket));
}
onFrontendDisconnect(socket) {
@ -73,4 +74,17 @@ export default class ProxyInterceptor {
const socket = socketMap[socketID];
socket.onProxiedEventReceived.apply(socket, [event].concat(args));
}
onSocketDisconnect(frontendConnection, socketID) {
const mapKey = frontendConnection.endpoint;
const socketMap = this.frontendProxiedSockets[mapKey];
if (!socketMap || !socketMap.hasOwnProperty(socketID)) {
logger.error(`Received SocketDisconnectEvent for nonexistent socket`,
{ socketID });
return;
}
const socket = socketMap[socketID];
socket.onProxiedEventReceived.apply(socket, ['disconnect']);
}
}