From b353bf5536d7372cdf7f2ff9fb65f0efc98f520e Mon Sep 17 00:00:00 2001 From: oneRain Date: Tue, 23 Jun 2020 18:37:09 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E8=B0=83=E6=95=B4=20goaway=20?= =?UTF-8?q?=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Internal/Connection/LCConnection.cs | 3 +++ .../Controller/LCIMGoAwayController.cs | 19 ------------------- Realtime/Realtime/LCIMClient.cs | 8 -------- 3 files changed, 3 insertions(+), 27 deletions(-) delete mode 100644 Realtime/Realtime/Internal/Controller/LCIMGoAwayController.cs diff --git a/Realtime/Realtime/Internal/Connection/LCConnection.cs b/Realtime/Realtime/Internal/Connection/LCConnection.cs index 1d60bc7..2f11347 100644 --- a/Realtime/Realtime/Internal/Connection/LCConnection.cs +++ b/Realtime/Realtime/Internal/Connection/LCConnection.cs @@ -123,6 +123,7 @@ namespace LeanCloud.Realtime.Internal.Connection { /// /// internal async Task Reset() { + state = State.Closed; heartBeat?.Stop(); // 关闭就连接 await ws.Close(); @@ -205,6 +206,8 @@ namespace LeanCloud.Realtime.Internal.Connection { } else { if (command.Cmd == CommandType.Echo) { heartBeat.Pong(); + } else if (command.Cmd == CommandType.Goaway) { + _ = Reset(); } else { // 通知 if (idToClients.TryGetValue(command.PeerId, out LCIMClient client)) { diff --git a/Realtime/Realtime/Internal/Controller/LCIMGoAwayController.cs b/Realtime/Realtime/Internal/Controller/LCIMGoAwayController.cs deleted file mode 100644 index 35d4518..0000000 --- a/Realtime/Realtime/Internal/Controller/LCIMGoAwayController.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System.Threading.Tasks; -using LeanCloud.Realtime.Internal.Protocol; - -namespace LeanCloud.Realtime.Internal.Controller { - internal class LCIMGoAwayController : LCIMController { - internal LCIMGoAwayController(LCIMClient client) : base(client) { - - } - - #region 消息处理 - - internal override void HandleNotification(GenericCommand notification) { - // 清空缓存,断开连接,等待重新连接 - _ = Connection.Reset(); - } - - #endregion - } -} diff --git a/Realtime/Realtime/LCIMClient.cs b/Realtime/Realtime/LCIMClient.cs index 6402076..6e08d3c 100644 --- a/Realtime/Realtime/LCIMClient.cs +++ b/Realtime/Realtime/LCIMClient.cs @@ -240,10 +240,6 @@ namespace LeanCloud.Realtime { get; private set; } - internal LCIMGoAwayController GoAwayController { - get; private set; - } - internal LCIMConversationController ConversationController { get; private set; } @@ -290,7 +286,6 @@ namespace LeanCloud.Realtime { SessionController = new LCIMSessionController(this); ConversationController = new LCIMConversationController(this); MessageController = new LCIMMessageController(this); - GoAwayController = new LCIMGoAwayController(this); } /// @@ -451,9 +446,6 @@ namespace LeanCloud.Realtime { case CommandType.Rcp: MessageController.HandleNotification(notification); break; - case CommandType.Goaway: - GoAwayController.HandleNotification(notification); - break; default: break; }