Send additional data on socket connection

前端 未结 7 511
清酒与你
清酒与你 2020-12-24 10:12

How to best send additional data upon socket connection?

Client:

socket.on(\'connect\',function(){ 
//I\'d like set some values and pass them up to t         


        
7条回答
  •  佛祖请我去吃肉
    2020-12-24 10:55

    I'm assuming you will use SSL.

    Using querystrings to send sensitive data is not a good security practice (why?). I think that if you need to send non-sensitive data, then Miquel answer is the fastest and more easy one, but if sensitive data is what you need to send, then something like Daniel W. is the best approach to take.

    For an authentication approach, you can take a look at this github project (socketio-auth) which, beyond the fact that it is currently with no maintenance, can give you a good idea of how to deal with the problem.

提交回复
热议问题