-
Notifications
You must be signed in to change notification settings - Fork 85
Multiple WebSocket standard support
WebSocketListener
can work with multiple implementation of the protocol simultaneously. The negotiation ensures that each client connect to the implementation it supports or fail if the version requested is not supported.
To add an implementation, a class derived from vtortola.WebSockets.WebSocketFactory
must be created, and registered in the listener before start:
var server = new WebSocketListener(new IPEndPoint(IPAddress.Any, 8006));
var rfc6455 = new vtortola.WebSockets.Rfc6455.WebSocketFactoryRfc6455(server);
server.Standards.RegisterStandard(rfc6455);
Note that different standards must have a different version number. It is possible to register different [Message Extensions] (//github.com/vtortola/WebSocketListener/wiki/WebSocketListener-Extensions) in each standard implementation:
var server = new WebSocketListener(new IPEndPoint(IPAddress.Any, 8006));
var rfc6455 = new vtortola.WebSockets.Rfc6455.WebSocketFactoryRfc6455(server);
rfc6455.MessageExtensions.RegisterExtension(new WebSocketDeflateExtension());
server.Standards.RegisterStandard(rfc6455)
Note that [Connection extensions] (//github.com/vtortola/WebSocketListener/wiki/WebSocketListener-Extensions) applies to the listener, no to particular standards (since all share the same endpoint).