diff --git a/Realtime/Internal/WebSocket/LCWebSocketConnection.cs b/Realtime/Internal/WebSocket/LCWebSocketConnection.cs index a78632c..30996f7 100644 --- a/Realtime/Internal/WebSocket/LCWebSocketConnection.cs +++ b/Realtime/Internal/WebSocket/LCWebSocketConnection.cs @@ -21,11 +21,14 @@ namespace LeanCloud.Realtime.Internal.WebSocket { private Dictionary> responses; + private string id; + internal Action OnNotification { get; set; } - internal LCWebSocketConnection() { + internal LCWebSocketConnection(string id) { + this.id = id; responses = new Dictionary>(); } @@ -44,11 +47,11 @@ namespace LeanCloud.Realtime.Internal.WebSocket { TaskCompletionSource tcs = new TaskCompletionSource(); request.I = RequestI; responses.Add(request.I, tcs); - LCLogger.Debug($"=> {request.Cmd}/{request.Op}: {request.ToString()}"); + LCLogger.Debug($"{id} => {request.Cmd}/{request.Op}: {request.ToString()}"); ArraySegment bytes = new ArraySegment(request.ToByteArray()); try { ws.SendAsync(bytes, WebSocketMessageType.Binary, true, default); - } catch (Exception e) { + } catch (Exception) { // TODO 发送消息异常 } @@ -80,7 +83,7 @@ namespace LeanCloud.Realtime.Internal.WebSocket { } while (!result.EndOfMessage); try { GenericCommand command = GenericCommand.Parser.ParseFrom(data); - LCLogger.Debug($"<= {command.Cmd}/{command.Op}: {command.ToString()}"); + LCLogger.Debug($"{id} <= {command.Cmd}/{command.Op}: {command.ToString()}"); HandleCommand(command); } catch (Exception e) { // 解析消息错误 diff --git a/Realtime/LCIMClient.cs b/Realtime/LCIMClient.cs index c8a6f0e..495fdc6 100644 --- a/Realtime/LCIMClient.cs +++ b/Realtime/LCIMClient.cs @@ -89,7 +89,7 @@ namespace LeanCloud.Realtime { /// /// public async Task Open() { - connection = new LCWebSocketConnection { + connection = new LCWebSocketConnection(ClientId) { OnNotification = OnNotification }; await connection.Connect();