B
B
batya152015-02-24 23:32:38
JavaScript
batya15, 2015-02-24 23:32:38

How to get a common handshake between different namespaces in socket.io?

During the application, the same client connects to the server using different namespaces.

var nsp = io.of('/my-namespace');
nsp.use(function (client, next){
    client.handshake.userId = 1;
    next();
});

var nsp2 = io.of('/my-tho');
nsp2.use(function (client, next){
    console.log(client.handshake.userId); // - > undefined
    next();
});

How to get the right handshake in the second case

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Avilov, 2015-02-24
@TheCreator

Through a global variable

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question