Last active
January 3, 2016 04:23
-
-
Save jdeisenberg/597f5121fd2d1906ea30 to your computer and use it in GitHub Desktop.
socket stuff
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
var sockets = [null, null, null]; | |
var areas = ["main", "auxiliary", "extras"]; | |
function receive_message(event) { | |
console.log(event.data); | |
} | |
function open_connections() { | |
for (var i = 0; i < sockets.length; i++) { | |
sockets[i] = new WebSocket("ws://localhost:3001"); | |
sockets[i].onmessage = receive_message; | |
var closure_fcn = function(socket, area) { | |
return function(event) { | |
console.log(socket); | |
console.log(area); | |
socket.send(area); | |
} | |
} | |
sockets[i].onopen = closure_fcn(sockets[i], areas[i]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment