chore: 简化 Connection

oneRain 2020-06-23 16:16:21 +08:00
parent 772a00f520
commit 4d9769eeb7
1 changed files with 3 additions and 19 deletions

View File

@ -54,21 +54,6 @@ namespace LeanCloud.Realtime.Internal.Connection {
/// </summary> /// </summary>
private const string SUB_PROTOCOL = "lc.protobuf2.3"; private const string SUB_PROTOCOL = "lc.protobuf2.3";
/// <summary>
/// 通知事件
/// </summary>
internal Action<GenericCommand> OnNotification;
/// <summary>
/// 断线事件
/// </summary>
internal Action OnDisconnect;
/// <summary>
/// 重连成功事件
/// </summary>
internal Action OnReconnected;
internal string id; internal string id;
/// <summary> /// <summary>
@ -190,9 +175,6 @@ namespace LeanCloud.Realtime.Internal.Connection {
/// <returns></returns> /// <returns></returns>
internal async Task Close() { internal async Task Close() {
LCRealtime.RemoveConnection(this); LCRealtime.RemoveConnection(this);
OnNotification = null;
OnDisconnect = null;
OnReconnected = null;
heartBeat.Stop(); heartBeat.Stop();
await ws.Close(); await ws.Close();
} }
@ -277,7 +259,9 @@ namespace LeanCloud.Realtime.Internal.Connection {
LCLogger.Debug("Reconnected"); LCLogger.Debug("Reconnected");
ws.OnMessage = OnClientMessage; ws.OnMessage = OnClientMessage;
ws.OnClose = OnClientDisconnect; ws.OnClose = OnClientDisconnect;
OnReconnected?.Invoke(); foreach (LCIMClient client in clients.Values) {
client.HandleReconnected();
}
break; break;
} else { } else {
// 重置 Router继续尝试重连 // 重置 Router继续尝试重连