feat: improve IRC command handling with debug logging for incoming messages

This commit is contained in:
HueByte
2026-02-23 10:54:02 +01:00
parent c2a8e9cfc8
commit 3c760b0bd8
2 changed files with 5 additions and 2 deletions
@@ -44,8 +44,9 @@ public sealed class IrcClientConnection : IAsyncDisposable
public IrcClientConnection(TcpClient tcpClient, Stream stream) public IrcClientConnection(TcpClient tcpClient, Stream stream)
{ {
_tcpClient = tcpClient; _tcpClient = tcpClient;
_reader = new StreamReader(stream, Encoding.UTF8); var utf8NoBom = new UTF8Encoding(encoderShouldEmitUTF8Identifier: false);
_writer = new StreamWriter(stream, Encoding.UTF8) { AutoFlush = true, NewLine = "\r\n" }; _reader = new StreamReader(stream, utf8NoBom);
_writer = new StreamWriter(stream, utf8NoBom) { AutoFlush = true, NewLine = "\r\n" };
} }
public async Task<string?> ReadLineAsync(CancellationToken ct) public async Task<string?> ReadLineAsync(CancellationToken ct)
@@ -44,6 +44,8 @@ public sealed class IrcCommandHandler
line = line.TrimEnd('\r', '\n'); line = line.TrimEnd('\r', '\n');
if (string.IsNullOrWhiteSpace(line)) continue; if (string.IsNullOrWhiteSpace(line)) continue;
_logger.LogDebug("IRC < {Id}: {Line}", _conn.ConnectionId, line);
var msg = IrcMessage.Parse(line); var msg = IrcMessage.Parse(line);
try try