I wrote a code for broadcasting a message to all users:
// websocket and http servers
var webSocketServer = require(\'websocket\').server;
...
...
v
For people using ws
version 3 or above. If you want to use the answer provided by @ma11hew28, simply change this block as following.
webSocketServer.on('connection', function (webSocket) {
var userID = parseInt(webSocket.upgradeReq.url.substr(1), 10)
webSocketServer.on('connection', function (webSocket, req) {
var userID = parseInt(req.url.substr(1), 10)
ws
package has moved upgradeReq to request object and you can check the following link for further detail.
Reference: https://github.com/websockets/ws/issues/1114