Skip to content

Instantly share code, notes, and snippets.

@keithmgould
Created May 20, 2012 15:23
Show Gist options
  • Save keithmgould/2758498 to your computer and use it in GitHub Desktop.
Save keithmgould/2758498 to your computer and use it in GitHub Desktop.
transport core extension
CHAT.namespace("CHAT.CORE");
CHAT.CORE.transport = (function () {
var socket = io.connect("http://chat.local:3000"),
sendables = ["new-message"];
// not happy with the location of this functionality
socket.on("new-message", function (msg) {
CHAT.CORE.modules.emit({ type : "receive-message", data : msg});
});
return {
emit : function (msg) {
var sendable,
i = 0;
for( ; sendable = sendables[i++] ; ){
if (sendable === msg.type){
socket.emit(msg.type, msg.data );
}
}
}
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment