-
Notifications
You must be signed in to change notification settings - Fork 85
Changes from version 1 to 2
These are the changes in the API since version 1.1.1:
- It now supports different WebSocket protocol versions simultaneously. Now the listener requires that at least one standard is registered before start:
var rfc6455 = new vtortola.WebSockets.Rfc6455.WebSocketFactoryRfc6455(server);
server.Standards.RegisterImplementation(rfc6455);
server.Start();
- Message extensions are now appended to the WebSocket implementations, rather than in the listener itself, so it is possible to enable different extensions for each WebSocket implementation.
var rfc6455 = new vtortola.WebSockets.Rfc6455.WebSocketFactoryRfc6455(server);
rfc6455.MessageExtensions.RegisterExtension(new WebSocketDeflateExtension());
server.Standards.RegisterImplementation(rfc6455);
-
It is possible to flush asynchronously and still be able of pushing more data. This is handy for doing streaming, since buffering is by default.
-
It is possible to close asynchronously. This is the best way of ending a message.
using (var messageWriter = ws.CreateMessageWriter(WebSocketMessageType.Text))
{
await messageReader.CopyToAsync(messageWriter).ConfigureAwait(false);
await messageWriter.CloseAsync(cancellation).ConfigureAwait(false);
}
-
It now measures latency. If the WebSocket implementation fulfill the contract
IWebSocketLatencyMeasure
, it will expose aLatency
property that tells the latency of the last ping.WebSocketFactoryRfc6455
implementation fulfills this contract. -
BufferManager: Now in the options, it is possible to pass a BufferManager object, that will be used to instantiate the
Byte[]
each WebSocket uses. -
More memory efficient. Each WebSocket uses now a single
Byte[]
array, and no other arrays are created.