Created
May 20, 2012 15:23
-
-
Save keithmgould/2758498 to your computer and use it in GitHub Desktop.
transport core extension
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
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