这个信息,因为socket.io 1.0
已被弃用,有授权的方法有两种:全局或命名空间(思路线)。全局方法在配置调用io.set('authorization', function (handshakeData, callback)
的服务器上设置。
的handshakeData对象包含下列信息:
{
headers: req.headers // <Object> the headers of the request
, time: (new Date) +'' // <String> date time of the connection
, address: socket.address() // <Object> remoteAddress and remotePort object
, xdomain: !!headers.origin // <Boolean> was it a cross domain request?
, secure: socket.secure // <Boolean> https connection
, issued: +date // <Number> EPOCH of when the handshake was created
, url: request.url // <String> the entrance path of the request
, query: data.query // <Object> the result of url.parse().query or a empty object
}
的上述信息和更深的解释是可在此 documentation page。
当套接字客户端发出请求,它已经请求头与它。你是说,你要改变这些,或者你只是想从套接字客户端发送一些记号,并根据您要授权客户端的令牌???? –
我想在标题中发送一个标记。 @MOmayr – Ziyu
您可以在查询字符串中发送该令牌并在授权功能中对其进行检查。我应该给你一个例子吗? –