* LCConnection.cs:
* LCWebSocketClient.cs: * LCIMSessionController.cs: * LCIMConversationController.cs: * LCIMClient.cs: chore: 实现在重连时如果被踢掉则关闭连接的情况
parent
bb3baf2ce8
commit
f5c56e5a34
|
@ -27,7 +27,7 @@ namespace LeanCloud.Realtime.Internal.Connection {
|
|||
/// <summary>
|
||||
/// 重连间隔
|
||||
/// </summary>
|
||||
private const int RECONNECT_INTERVAL = 5000;
|
||||
private const int RECONNECT_INTERVAL = 10000;
|
||||
|
||||
/// <summary>
|
||||
/// 心跳间隔
|
||||
|
|
|
@ -632,9 +632,9 @@ namespace LeanCloud.Realtime.Internal.Controller {
|
|||
/// <returns></returns>
|
||||
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);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -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);
|
||||
if (response.Op == OpType.Opened) {
|
||||
UpdateSession(response.SessionMessage);
|
||||
} else if (response.Op == OpType.Closed) {
|
||||
await OnClosed(response.SessionMessage);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -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
|
||||
|
|
|
@ -120,7 +120,6 @@ namespace LeanCloud.Realtime.Internal.WebSocket {
|
|||
} catch (Exception e) {
|
||||
LCLogger.Error(e);
|
||||
} finally {
|
||||
// TODO 正常关闭不知道能否完成???
|
||||
OnDisconnect?.Invoke();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ namespace LeanCloud.Realtime {
|
|||
/// <summary>
|
||||
/// 当前客户端被服务端强行下线
|
||||
/// </summary>
|
||||
public Action<int, string, string> OnClose {
|
||||
public Action<int, string> OnClose {
|
||||
get; set;
|
||||
}
|
||||
|
||||
|
@ -459,7 +459,7 @@ namespace LeanCloud.Realtime {
|
|||
LCLogger.Error(e);
|
||||
await Connection.Close();
|
||||
// TODO 告知
|
||||
//OnClose?.Invoke();
|
||||
OnClose?.Invoke(0, string.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue