/// <summary> /// 开始自动重连 /// </summary> public void StartAutoReconnect() { if (!autoReconnectionStarted && CanReconnect) { autoReconnectionStarted = true; reconnectTimer = new AVTimer(); reconnectTimer.Interval = this.ReconnectOptions.Interval * 1000; reconnectTimer.Elapsed += ReconnectTimer_Elapsed; reconnectTimer.Start(); reconnectTimer.Enabled = true; } }
/// <summary> /// 主动发送心跳包 /// </summary> /// <param name="toggle">是否开启</param> /// <param name="interval">时间间隔</param> /// <param name="beatPacket">心跳包的内容,默认是个空的 {}</param> public void ToggleHeartBeating(bool toggle = true, double interval = 60000, string beatPacket = "{}") { this._heartBeatingToggle = toggle; if (!string.Equals(_beatPacket, beatPacket)) { _beatPacket = beatPacket; } if (_heartBeatingTimer == null) { _heartBeatingTimer = new AVTimer(); _heartBeatingTimer.Elapsed += SendHeartBeatingPacket; _heartBeatingTimer.Interval = interval; _heartBeatingTimer.Start(); PrintLog("auto heart beating started."); } }