Commit d65b2baa authored by AfirSraftGarrier's avatar AfirSraftGarrier

格式并加些打印

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