最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Specific options to nodejs ws.Server - Stack Overflow

programmeradmin1浏览0评论

Can someone explain me what disableHixie, clientTracking in nodejs websocket library 'ws' means:

new ws.Server([options], [callback])

options Object
host String
port Number
server http.Server
verifyClient Function
path String
noServer Boolean
disableHixie Boolean
clientTracking Boolean
callback Function

I can't find a conclusive description what it means.

Can someone explain me what disableHixie, clientTracking in nodejs websocket library 'ws' means:

new ws.Server([options], [callback])

options Object
host String
port Number
server http.Server
verifyClient Function
path String
noServer Boolean
disableHixie Boolean
clientTracking Boolean
callback Function

I can't find a conclusive description what it means.

Share Improve this question asked Aug 23, 2013 at 10:22 Luman75Luman75 9081 gold badge12 silver badges28 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 18

Hixie-76 is an old and deprecated protocol supported by WebSocket, but this protocol is still in use in some versions of Safari and Opera. Default value in library 'ws' is false, but you can disable the setting and set the disableHixie option to true.

The clientTracking option provides access to a collection of active WebSocket clients. Default value is true. See below:

var wss = new WebSocketServer({server:app });

wss.on('connection', function (ws) {
   .....
   console.log('Total clients: ', wss.clients.length);
   ....
}

Edit: additional information:

The verifyClient function allows you to add any custom code to accept or reject incoming connections. Your code receives an info object with three members:

  • info.origin: The origin of the connection
  • info.secure: True if this connection is authorized or encrypted
  • info.req: The http.Server request object for this connection

The verifyClient function can take one of the two forms:

var wss1 = new WebSocketServer ({ ..., 
   verifyClient: function(info) {
      # ...check data in info and return true or false...
   }
);

var wss2 = new WebSocketServer ({ ..., 
   verifyClient: function(info, callback){
      # ...check data in info and call
      # callback(true) for success or
      # callback(false) for failure 
   }
});

The first form is simpler if you can validate the client immediately. For asynchronous validation, use the second form.

发布评论

评论列表(0)

  1. 暂无评论