TsgcWebSocketClientProperties › HeartBeat

HeartBeat Property

Sends periodic WebSocket ping frames to keep the connection alive.

Syntax

public TsgcWSHeartBeat_Options HeartBeat { get; set; }

Default Value

Enabled=False

Remarks

When HeartBeat.Enabled is True, the client sends a ping every Interval seconds. Sub-properties include Timeout (maximum seconds between ping and pong before the connection is closed, 0 to disable) and HeartBeatType: hbtAlways sends a ping on every interval, while hbtOnlyIfNoMsgRcvInterval only pings when no message has been received during the last interval. The OnBeforeHeartBeat event lets you replace the default ping with a custom message.

Example


oClient = new TsgcWebSocketClient();
oClient.HeartBeat.Interval = 30;
oClient.HeartBeat.Timeout = 0;
oClient.HeartBeat.Enabled = true;
oClient.Active = true;

Back to Properties