chore: 简化 Connection
parent
772a00f520
commit
4d9769eeb7
|
@ -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,继续尝试重连
|
||||||
|
|
Loading…
Reference in New Issue