einaros/ws — pull request #126 by kanaka (2012-10-26 18:41:35+00:00)
Title: Allow application selection of subprotocol value

If the handleProtocols attribute is set in the options for
WebSocketServer then this function will be called to select
a subprotocol otherwise the first subprotocol sent by the client will
be returned.

The handleProtocols function takes two arguments: a list of subprotocol
strings and a callback. The callback takes two arguments: the result
and the selected subprotocol. The handleProtocols handler routine
should select a subprotocol from the subprotocols first argument based
on whatever criteria the application uses and call the callback with
first argument set to true and the selected subprotocol string as the
second argument. If the application determines that the client
subprotocol list does not have a valid subprotocol then it should call
the callback with a false first argument. This will cause the
handshake to fail with a 404 (not found) error.