Answer the question
In order to leave comments, you need to log in
How to get parameters from client when connecting on server side WebSocket in nodeJs?
Greetings!
There is a simple web socket server. He doesn't know how to do anything yet.
webSocketServer.on('connection', function (ws) {
let id = lastId++;
clients[id] = ws;
console.log("новое соединение " + id);
ws.send(JSON.stringify({"You are": "connected"}));
ws.on('message', function (message) {
console.log('получено сообщение ' + message);
});
ws.on('close', function () {
console.log('соединение закрыто ' + id);
delete clients[id];
});
});
client.connect('ws://localhost:8081/', 'echo-protocol');
client.connect('ws://localhost:8081/?some_id=12345', 'echo-protocol');
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question