add logger to handler

This commit is contained in:
afrokick 2019-04-01 15:10:54 +03:00
parent 654f3c9c3c
commit 0aa52c488a

View File

@ -23,6 +23,7 @@ const handler = (client, message) => {
throw new Error('Peer dead');
}
} catch (e) {
logger.error(e);
// This happens when a peer disconnects without closing connections and
// the associated WebSocket has not closed.
// Tell other side to stop trying.
@ -42,8 +43,10 @@ const handler = (client, message) => {
// Wait for this client to connect/reconnect (XHR) for important
// messages.
if (type !== MessageType.LEAVE && type !== MessageType.EXPIRE && dstId) {
logger.debug(`[HANDLER] dst client ${dstId} not found, add msg to queue`);
realm.addMessageToQueue(dstId, message);
} else if (type === MessageType.LEAVE && !dstId) {
logger.debug(`[HANDLER] remove client ${srcId}`);
realm.removeClientById(srcId);
} else {
// Unavailable destination specified with message LEAVE or EXPIRE