Advanced Customizations¶
SendPings¶
Set to true
to let the plugin send ping messages periodically to the server. Its default value is false. It's not available under WebGL!
Example
PingFrequency¶
The delay between two ping messages in milliseconds. Its default value is 1000 (1 second). It's not available under WebGL!
Example
CloseAfterNoMesssage¶
If SendPing
set to true, the plugin will close the connection and emit an OnClosed
event if no message is received from the server in the given time. Its default value is 2 sec. It's not available under WebGL!
Example
InternalRequest¶
It's NOT available under WebGL! Unfortunately, under WebGL there's no way to add any header to the request, but you can let your voice heard!
The internal HTTPRequest
object the plugin uses to send the websocket upgrade request to the server. To customize this internal request, use the OnInternalRequestCreated
callback:
The plugin might call it more than once for one WebSocket instance if it has to fall back from the HTTP/2 implementation to HTTP/1.
Extensions¶
Extensions are additions to the WebSocket protocols that must be negotiated first with the server to be able to use. The Best WebSockets package supports and uses the Per-Message Compression Extension by default.
IExtension
implementations the plugin will negotiate with the server to use. It's not available under WebGL!
Latency¶
If SendPings
is set to true
, the plugin going to calculate Latency from the ping-pong message round-trip times. It's not available under WebGL!
LastMessageReceived¶
When the last message is received from the server. It's not available under WebGL!
Per-Message Compression Extension¶
The plugin enables and uses the Per-Message Compression Extension by default. It can be disabled by passing null as the last (extensions) parameter of the websocket constructor. To change defaults we can use the same constructor, but with a new PerMessageCompression
object:
Example
Extension usage depends on the server too, but if the server agrees to use the extension, the plugin can receive and send compressed messages automatically.