* 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>
|
||||||
/// 重连间隔
|
/// 重连间隔
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private const int RECONNECT_INTERVAL = 5000;
|
private const int RECONNECT_INTERVAL = 10000;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 心跳间隔
|
/// 心跳间隔
|
||||||
|
|
|
@ -632,9 +632,9 @@ namespace LeanCloud.Realtime.Internal.Controller {
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
private async Task OnLeft(ConvCommand convMessage) {
|
private async Task OnLeft(ConvCommand convMessage) {
|
||||||
LCIMConversation conversation = await Client.GetOrQueryConversation(convMessage.Cid);
|
LCIMConversation conversation = await Client.GetOrQueryConversation(convMessage.Cid);
|
||||||
Client.OnKicked?.Invoke(conversation, convMessage.InitBy);
|
|
||||||
// TODO 从内存中清除对话
|
// TODO 从内存中清除对话
|
||||||
|
|
||||||
|
Client.OnKicked?.Invoke(conversation, convMessage.InitBy);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -37,7 +37,11 @@ namespace LeanCloud.Realtime.Internal.Controller {
|
||||||
GenericCommand request = NewCommand(CommandType.Session, OpType.Open);
|
GenericCommand request = NewCommand(CommandType.Session, OpType.Open);
|
||||||
request.SessionMessage = session;
|
request.SessionMessage = session;
|
||||||
GenericCommand response = await Client.Connection.SendRequest(request);
|
GenericCommand response = await Client.Connection.SendRequest(request);
|
||||||
|
if (response.Op == OpType.Opened) {
|
||||||
UpdateSession(response.SessionMessage);
|
UpdateSession(response.SessionMessage);
|
||||||
|
} else if (response.Op == OpType.Closed) {
|
||||||
|
await OnClosed(response.SessionMessage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -119,7 +123,7 @@ namespace LeanCloud.Realtime.Internal.Controller {
|
||||||
string reason = session.Reason;
|
string reason = session.Reason;
|
||||||
string detail = session.Detail;
|
string detail = session.Detail;
|
||||||
await Connection.Close();
|
await Connection.Close();
|
||||||
Client.OnClose?.Invoke(code, reason, detail);
|
Client.OnClose?.Invoke(code, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
@ -120,7 +120,6 @@ namespace LeanCloud.Realtime.Internal.WebSocket {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LCLogger.Error(e);
|
LCLogger.Error(e);
|
||||||
} finally {
|
} finally {
|
||||||
// TODO 正常关闭不知道能否完成???
|
|
||||||
OnDisconnect?.Invoke();
|
OnDisconnect?.Invoke();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@ namespace LeanCloud.Realtime {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 当前客户端被服务端强行下线
|
/// 当前客户端被服务端强行下线
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Action<int, string, string> OnClose {
|
public Action<int, string> OnClose {
|
||||||
get; set;
|
get; set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -459,7 +459,7 @@ namespace LeanCloud.Realtime {
|
||||||
LCLogger.Error(e);
|
LCLogger.Error(e);
|
||||||
await Connection.Close();
|
await Connection.Close();
|
||||||
// TODO 告知
|
// TODO 告知
|
||||||
//OnClose?.Invoke();
|
OnClose?.Invoke(0, string.Empty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue