Commit 83e9f4c9 authored by zengtianlai3's avatar zengtianlai3

.

parent 5996305f
......@@ -63,9 +63,9 @@ public class DeviceServerHandler extends SimpleChannelInboundHandler<Object> {
auth = handlerCheckAuth(channel, remoteIp, remotePort, protocol);
} else {
auth = handlerCheckAuthStatus(channel, remoteIp, remotePort, protocol);
auth = handlerCheckAuthStatus(channel);
if (auth) {
handlerForward(channel, remoteIp, remotePort, protocol);
handlerForward(channel, protocol);
}
}
......@@ -163,13 +163,13 @@ public class DeviceServerHandler extends SimpleChannelInboundHandler<Object> {
return license;
}
private boolean handlerCheckAuthStatus(SocketChannel channel, String remoteIp, int remotePort, DeviceProtocol protocol) {
private boolean handlerCheckAuthStatus(SocketChannel channel) {
String channelId = channel.id().asLongText();
DeviceManager deviceManager = SpringUtil.getBean(DeviceManager.class);
return deviceManager.getAuthStatusByChannelId(channelId);
}
private void handlerForward(SocketChannel channel, String remoteIp, int remotePort, DeviceProtocol protocol) {
private void handlerForward(SocketChannel channel, DeviceProtocol protocol) {
String channelId = channel.id().asLongText();
ForwardClientRequestEvent forwardClientRequestEvent = new ForwardClientRequestEvent();
forwardClientRequestEvent.setDeviceChannelId(channelId);
......
......@@ -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
......@@ -33,9 +31,6 @@ public class ForwardClientHandler extends SimpleChannelInboundHandler<Object> {
// TODO Auto-generated method stub
// TODO 中转客户端收到消息后,将消息原封不动的发送给设备客户端
SocketChannel channel = (SocketChannel) ctx.channel();
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()));
......
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