Last active
May 16, 2017 22:09
-
-
Save arqex/ed97472cad69b38369dbeb3965a49d7e to your computer and use it in GitHub Desktop.
Socket event hub
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This helper will guide our websocket events to freezer | |
function toFreezer( socketEvent, freezerEvent ){ | |
socket.on( socketEvent, function(){ | |
var args = [freezerEvent].concat( Array.from(arguments) ); | |
freezer.emit.apply( freezer, args ); | |
}); | |
} | |
// Now we can redirect socket events easily | |
toFreezer('messageReceived', 'message:received'); | |
toFreezer('friendshipAccepted', 'friend:add'); | |
toFreezer('friendOnline', 'user:add'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment