Socket IO | How to get the client transport type on the serverside?

后端 未结 7 806
梦谈多话
梦谈多话 2021-01-01 23:51

I need to know what transport method a client is using for some conditional statements on the nodeJS serverside.

Does anyone know how I can get that

7条回答
  •  悲哀的现实
    2021-01-02 00:10

    for reference's sake and google stumbles:- in case anyone is still using v0.9 (or possibly earlier) you can access this info from client side like this:

    var socket = io.connect();
    console.log(socket.socket.transport.name); //log the name of the transport being used.
    

    answer found on google groups https://groups.google.com/forum/#!topic/socket_io/yx_9wJiiAg0

提交回复
热议问题