@Override
public void channelRead0(final ChannelHandlerContext ctx, WebSocketFrame frame) throws Exception {
webSocketServerThread.log(Level.FINEST, "channel read, frame="+frame);
// TODO: log at INFO level if this the first data we received from a client (new first connection), to
// help detect clients connecting but not sending authentication commands (in newPlayer)
if (this.checkIPBans) {
String ip = webSocketServerThread.getRemoteIP(ctx.channel());
if (this.ipBans.contains(ip)) {
webSocketServerThread.sendLine(ctx.channel(), "T,Banned from server"); // TODO: show reason, getBanList
return;
}
}
if (frame instanceof BinaryWebSocketFrame) {
ByteBuf content = frame.content();
byte[] bytes = new byte[content.capacity()];
content.getBytes(0, bytes);
final String string = new String(bytes);
webSocketServerThread.log(Level.FINEST, "received "+content.capacity()+" bytes: "+string);
this.webSocketServerThread.scheduleSyncTask(new Runnable() {
@Override
public void run() {
webSocketServerThread.handle(string, ctx);
}
});
} else {
String message = "unsupported frame type: " + frame.getClass().getName();
throw new UnsupportedOperationException(message);
}
}
WebSocketFrameHandler.java 文件源码
java
阅读 19
收藏 0
点赞 0
评论 0
项目:WebSandboxMC
作者:
评论列表
文章目录