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>
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;
/// <summary>
@ -190,9 +175,6 @@ namespace LeanCloud.Realtime.Internal.Connection {
/// <returns></returns>
internal async Task Close() {
LCRealtime.RemoveConnection(this);
OnNotification = null;
OnDisconnect = null;
OnReconnected = null;
heartBeat.Stop();
await ws.Close();
}
@ -277,7 +259,9 @@ namespace LeanCloud.Realtime.Internal.Connection {
LCLogger.Debug("Reconnected");
ws.OnMessage = OnClientMessage;
ws.OnClose = OnClientDisconnect;
OnReconnected?.Invoke();
foreach (LCIMClient client in clients.Values) {
client.HandleReconnected();
}
break;
} else {
// 重置 Router继续尝试重连