diff --git a/Realtime/Internal/Connection/LCConnection.cs b/Realtime/Internal/Connection/LCConnection.cs index afd313e..7204feb 100644 --- a/Realtime/Internal/Connection/LCConnection.cs +++ b/Realtime/Internal/Connection/LCConnection.cs @@ -27,7 +27,7 @@ namespace LeanCloud.Realtime.Internal.Connection { /// /// 重连间隔 /// - private const int RECONNECT_INTERVAL = 5000; + private const int RECONNECT_INTERVAL = 10000; /// /// 心跳间隔 diff --git a/Realtime/Internal/Controller/LCIMConversationController.cs b/Realtime/Internal/Controller/LCIMConversationController.cs index 0372b0e..c6143b5 100644 --- a/Realtime/Internal/Controller/LCIMConversationController.cs +++ b/Realtime/Internal/Controller/LCIMConversationController.cs @@ -632,9 +632,9 @@ namespace LeanCloud.Realtime.Internal.Controller { /// private async Task OnLeft(ConvCommand convMessage) { LCIMConversation conversation = await Client.GetOrQueryConversation(convMessage.Cid); - Client.OnKicked?.Invoke(conversation, convMessage.InitBy); // TODO 从内存中清除对话 + Client.OnKicked?.Invoke(conversation, convMessage.InitBy); } /// diff --git a/Realtime/Internal/Controller/LCIMSessionController.cs b/Realtime/Internal/Controller/LCIMSessionController.cs index 74dc524..894502e 100644 --- a/Realtime/Internal/Controller/LCIMSessionController.cs +++ b/Realtime/Internal/Controller/LCIMSessionController.cs @@ -37,7 +37,11 @@ namespace LeanCloud.Realtime.Internal.Controller { GenericCommand request = NewCommand(CommandType.Session, OpType.Open); request.SessionMessage = session; GenericCommand response = await Client.Connection.SendRequest(request); - UpdateSession(response.SessionMessage); + if (response.Op == OpType.Opened) { + UpdateSession(response.SessionMessage); + } else if (response.Op == OpType.Closed) { + await OnClosed(response.SessionMessage); + } } /// @@ -119,7 +123,7 @@ namespace LeanCloud.Realtime.Internal.Controller { string reason = session.Reason; string detail = session.Detail; await Connection.Close(); - Client.OnClose?.Invoke(code, reason, detail); + Client.OnClose?.Invoke(code, reason); } #endregion diff --git a/Realtime/Internal/WebSocket/LCWebSocketClient.cs b/Realtime/Internal/WebSocket/LCWebSocketClient.cs index c12bbe8..5d80ccc 100644 --- a/Realtime/Internal/WebSocket/LCWebSocketClient.cs +++ b/Realtime/Internal/WebSocket/LCWebSocketClient.cs @@ -120,7 +120,6 @@ namespace LeanCloud.Realtime.Internal.WebSocket { } catch (Exception e) { LCLogger.Error(e); } finally { - // TODO 正常关闭不知道能否完成??? OnDisconnect?.Invoke(); } } diff --git a/Realtime/LCIMClient.cs b/Realtime/LCIMClient.cs index 0f0d4f8..ded9bce 100644 --- a/Realtime/LCIMClient.cs +++ b/Realtime/LCIMClient.cs @@ -66,7 +66,7 @@ namespace LeanCloud.Realtime { /// /// 当前客户端被服务端强行下线 /// - public Action OnClose { + public Action OnClose { get; set; } @@ -459,7 +459,7 @@ namespace LeanCloud.Realtime { LCLogger.Error(e); await Connection.Close(); // TODO 告知 - //OnClose?.Invoke(); + OnClose?.Invoke(0, string.Empty); } }