Skip to content

Commit 6d13db3

Browse files
author
Eugen Freiter
committed
put debugData back
Signed-off-by: Eugen Freiter <[email protected]>
1 parent 1720a25 commit 6d13db3

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/main/java/io/github/hapjava/server/impl/http/impl/BinaryHandler.java

+12
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import io.netty.channel.ChannelHandlerContext;
77
import io.netty.handler.codec.ByteToMessageCodec;
88
import java.io.IOException;
9+
import java.nio.charset.StandardCharsets;
910
import java.util.List;
1011
import org.slf4j.Logger;
1112
import org.slf4j.LoggerFactory;
@@ -24,6 +25,7 @@ public BinaryHandler(HomekitClientConnection connection) {
2425
@Override
2526
protected void encode(ChannelHandlerContext ctx, ByteBuf msg, ByteBuf out) throws Exception {
2627
if (started) {
28+
debugData("Sending data", msg, ctx);
2729
byte[] b = new byte[msg.readableBytes()];
2830
msg.readBytes(b);
2931
out.writeBytes(connection.encryptResponse(b));
@@ -38,6 +40,7 @@ protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) t
3840
in.readBytes(b);
3941
byte[] decrypted = connection.decryptRequest(b);
4042
ByteBuf outBuf = Unpooled.copiedBuffer(decrypted);
43+
debugData("Received data", outBuf, ctx);
4144
out.add(outBuf);
4245
started = true;
4346
}
@@ -52,4 +55,13 @@ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws E
5255
}
5356
super.exceptionCaught(ctx, cause);
5457
}
58+
59+
private void debugData(String msg, ByteBuf b, ChannelHandlerContext ctx) throws Exception {
60+
if (logger.isDebugEnabled()) {
61+
logger.debug(
62+
String.format(
63+
"%s [%s]:%n%s",
64+
msg, ctx.channel().remoteAddress().toString(), b.toString(StandardCharsets.UTF_8)));
65+
}
66+
}
5567
}

0 commit comments

Comments
 (0)