Xin
Xin

Reputation: 36490

How do I know connected socket.io client which transport is being used websocket or polling?

Is there a way that I can know the connected socket.io client which transport is using? e.g. websocket / polling

I am using "socket.io-client": "2.0.1" + "socket.io": "2.0.1"

Thanks.

Upvotes: 0

Views: 380

Answers (1)

mk12ok
mk12ok

Reputation: 1313

Server:

io.on('connection', function (socket) { 
        console.log(socket.conn.transport.name);
});

Client:

socket.io.engine.transport.name

Upvotes: 2

Related Questions