V
V
Vlad Timofeev2015-02-14 15:38:56
Node.js
Vlad Timofeev, 2015-02-14 15:38:56

How to get a client request from a Socket object?

Good day.
I use socket.io
How to get a client request from the Socket object? (The object that the server gives when rendering)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Тимур Шемсединов, 2015-02-15
@MarcusAurelius Куратор тега Node.js

Смотря какую библиотеку используете для сокетов, если websocket, то:

var websocket = require('websocket');
server.websocket = new websocket.server({ httpServer: server, autoAcceptConnections: false });
server.websocket.on('request', function(socket) {
  var req = socket.httpRequest;
  var res = socket.socket;
});

Если не знаете, что содержит socket у другой библиотеки, то выводите в консоль:
console.dir(Object.keys(socket));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question