diff --git a/Lagrange.OneBot/Core/Network/ReverseWSService.cs b/Lagrange.OneBot/Core/Network/ReverseWSService.cs index 46e526ccb..eca412108 100644 --- a/Lagrange.OneBot/Core/Network/ReverseWSService.cs +++ b/Lagrange.OneBot/Core/Network/ReverseWSService.cs @@ -10,6 +10,8 @@ namespace Lagrange.OneBot.Core.Network; public sealed class ReverseWSService : ILagrangeWebService { + private const string Tag = nameof(ReverseWSService); + public event EventHandler OnMessageReceived = delegate { }; private readonly WebsocketClient _socket; @@ -45,7 +47,11 @@ public ReverseWSService(IConfiguration config, ILogger logger) }); _timer = new Timer(OnHeartbeat, null, int.MaxValue, config.GetValue("Implementation:ReverseWebSocket:HeartBeatInterval")); - _socket.MessageReceived.Subscribe(resp => OnMessageReceived.Invoke(this, new(resp.Text ?? ""))); + _socket.MessageReceived.Subscribe(resp => + { + _logger.LogTrace($"[{Tag}] Receive: {resp.Text}"); + OnMessageReceived.Invoke(this, new MsgRecvEventArgs(resp.Text ?? "")); + }); } public async Task StartAsync(CancellationToken cancellationToken) @@ -66,7 +72,9 @@ public Task StopAsync(CancellationToken cancellationToken) public Task SendJsonAsync(T json, CancellationToken cancellationToken = default) { - var payload = JsonSerializer.SerializeToUtf8Bytes(json); + string payload = JsonSerializer.Serialize(json); + + _logger.LogTrace($"[{Tag}] Send: {payload}"); return _socket.SendInstant(payload); }