Commit d65b2baa authored by AfirSraftGarrier's avatar AfirSraftGarrier

格式并加些打印

parent 6bb21e5e
......@@ -8,7 +8,7 @@ import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.channel.socket.SocketChannel;
import iot.sixiang.license.auth.AuthManager;
import iot.sixiang.license.consts.Consts;
import iot.sixiang.license.event.CreateForwarClientEvent;
import iot.sixiang.license.event.CreateForwardClientEvent;
import iot.sixiang.license.event.DeviceClientInactiveEvent;
import iot.sixiang.license.event.EventPublisher;
import iot.sixiang.license.event.ForwardClientRequestEvent;
......@@ -143,7 +143,7 @@ public class DeviceServerHandler extends SimpleChannelInboundHandler<Object> {
deviceManager.putSession(appId, session);
// 创建透传的客户端
CreateForwarClientEvent event = new CreateForwarClientEvent();
CreateForwardClientEvent event = new CreateForwardClientEvent();
event.setAppId(appId);
eventPublisher.publishEvent(event);
}
......
......@@ -4,6 +4,6 @@ package iot.sixiang.license.event;
import lombok.Data;
@Data
public class CreateForwarClientEvent extends BaseEvent {
public class CreateForwardClientEvent extends BaseEvent {
private String appId;
}
......@@ -23,7 +23,7 @@ public class CreateForwardClientEventHandler {
}
@EventListener
public void handlerEvent(CreateForwarClientEvent event) {
public void handlerEvent(CreateForwardClientEvent event) {
String appId = event.getAppId();
Server balanceServer = balanceManager.getBalanceServer();
if (balanceServer != null) {
......
......@@ -13,8 +13,6 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.net.InetSocketAddress;
@Component
@ChannelHandler.Sharable
@Slf4j
......@@ -30,12 +28,12 @@ public class ForwardClientHandler extends SimpleChannelInboundHandler<Object> {
protected void channelRead0(ChannelHandlerContext ctx, Object msg) {
// 中转客户端收到消息后,将消息原封不动的发送给设备客户端
SocketChannel channel = (SocketChannel) ctx.channel();
InetSocketAddress socketAddr = (InetSocketAddress) ctx.channel().remoteAddress();
//InetSocketAddress socketAddr = (InetSocketAddress) ctx.channel().remoteAddress();
//String serverIp = socketAddr.getHostString();
//int serverPort = socketAddr.getPort();
DeviceProtocol protocol = (DeviceProtocol) msg;
String channelId = channel.id().asLongText();
log.debug("桥接客户端,channelRead0:{},{}", channelId, HexUtil.bytes2hex(protocol.getContent()));
log.info("桥接客户端,channelRead0:{},{}", channelId, HexUtil.bytes2hex(protocol.getContent()));
ForwardMessageResponseEvent forwardMessageResponseEvent = new ForwardMessageResponseEvent();
forwardMessageResponseEvent.setChannelId(channelId);
......@@ -48,13 +46,13 @@ public class ForwardClientHandler extends SimpleChannelInboundHandler<Object> {
@Override
public void channelRegistered(ChannelHandlerContext ctx) throws Exception {
super.channelRegistered(ctx);
log.debug("桥接客户端,channelRegistered:{}", ctx.channel().id().asLongText());
log.info("桥接客户端,channelRegistered:{}", ctx.channel().id().asLongText());
}
@Override
public synchronized void channelActive(ChannelHandlerContext ctx) throws Exception {
super.channelActive(ctx);
log.debug("桥接客户端,channelActive:{}", ctx.channel().id().asLongText());
log.info("桥接客户端,channelActive:{}", ctx.channel().id().asLongText());
}
@Override
......@@ -62,7 +60,7 @@ public class ForwardClientHandler extends SimpleChannelInboundHandler<Object> {
super.channelInactive(ctx);
SocketChannel channel = (SocketChannel) ctx.channel();
String channelId = channel.id().asLongText();
log.debug("桥接客户端,channelInactive:{}", channelId);
log.info("桥接客户端,channelInactive:{}", channelId);
ForwardClientInactiveEvent forwardClientInactiveEvent = new ForwardClientInactiveEvent();
forwardClientInactiveEvent.setChannelId(channelId);
......@@ -73,18 +71,18 @@ public class ForwardClientHandler extends SimpleChannelInboundHandler<Object> {
@Override
public void channelReadComplete(ChannelHandlerContext ctx) throws Exception {
super.channelReadComplete(ctx);
log.debug("桥接客户端,channelReadComplete:{}", ctx.channel().id().asLongText());
log.info("桥接客户端,channelReadComplete:{}", ctx.channel().id().asLongText());
}
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
super.exceptionCaught(ctx, cause);
log.debug("桥接客户端,exceptionCaught:{}", ctx.channel().id().asLongText());
log.info("桥接客户端,exceptionCaught:{}", ctx.channel().id().asLongText());
ctx.close();
}
@Override
public synchronized void userEventTriggered(ChannelHandlerContext ctx, Object obj) {
log.debug("桥接客户端,userEventTriggered:{}", ctx.channel().id().asLongText());
log.info("桥接客户端,userEventTriggered:{}", ctx.channel().id().asLongText());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment