socket = io(connectUrl + "?authkey=" + connectKey, {forceNew: true});
:and on the server side, there is something that looks like this
oServer = new IOServer(server);
ioServer.origins(appConfig.origins);
ioServer.use(verifyConnection);
ioServer.on('connection', onConnect);Notice the verifyConnection middleware being used, that looks like this, removing the unimportant bits...var verifyConnection = function(socket, next) {
var authkey = socket.request._query.authkey;
};
--
Job board: http://jobs.nodejs.org/
New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to a topic in the Google Groups "nodejs" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nodejs/DVNUsoEhoRM/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nodejs+un...@googlegroups.com.
To post to this group, send email to nod...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/0b7f961d-35a9-48e4-9dff-d79c9322f9bd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
To unsubscribe from this group and all its topics, send an email to nodejs+unsubscribe@googlegroups.com.
To post to this group, send email to nod...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/0b7f961d-35a9-48e4-9dff-d79c9322f9bd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/0128a2a5-4498-4689-a191-d71981307458%40googlegroups.com.
To unsubscribe from this group and all its topics, send an email to nodejs+un...@googlegroups.com.
To post to this group, send email to nod...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/0b7f961d-35a9-48e4-9dff-d79c9322f9bd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--Christopher MinaLive Healthy. Work Hard. Be Kind. Gain Success.
wss.on('connection', function(ws) {
numConnections++;
var message = JSON.stringify({
numConnections: numConnections,
event: "numConnectionsChanged"
});
wss.clients.forEach(function(client) {
client.send(message);
});
})
ws = new WebSocket(...);
ws.onmessage =function(event) {
var data = JSON.parse(event.data);
if (data.event == "numConnectionsChanged") {
var numberOfConnections = data.numConnections;
document.getElementById("my-counter").innerHTML = numberOfConnections;
}
}ws.on('close', function close() { numConnections--; ... alert all remaining sockets ...
});