Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
ioc_sixiang_license
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zengtianlai3
ioc_sixiang_license
Commits
d65b2baa
Commit
d65b2baa
authored
Nov 15, 2022
by
AfirSraftGarrier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
格式并加些打印
parent
6bb21e5e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
14 deletions
+12
-14
DeviceServerHandler.java
.../java/iot/sixiang/license/device/DeviceServerHandler.java
+2
-2
CreateForwardClientEvent.java
...a/iot/sixiang/license/event/CreateForwardClientEvent.java
+1
-1
CreateForwardClientEventHandler.java
...ixiang/license/event/CreateForwardClientEventHandler.java
+1
-1
ForwardClientHandler.java
...ava/iot/sixiang/license/forward/ForwardClientHandler.java
+8
-10
No files found.
license/src/main/java/iot/sixiang/license/device/DeviceServerHandler.java
View file @
d65b2baa
...
@@ -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.CreateForwar
d
ClientEvent
;
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
);
// 创建透传的客户端
// 创建透传的客户端
CreateForwar
ClientEvent
event
=
new
CreateForwar
ClientEvent
();
CreateForwar
dClientEvent
event
=
new
CreateForward
ClientEvent
();
event
.
setAppId
(
appId
);
event
.
setAppId
(
appId
);
eventPublisher
.
publishEvent
(
event
);
eventPublisher
.
publishEvent
(
event
);
}
}
...
...
license/src/main/java/iot/sixiang/license/event/CreateForwarClientEvent.java
→
license/src/main/java/iot/sixiang/license/event/CreateForwar
d
ClientEvent.java
View file @
d65b2baa
...
@@ -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
CreateForwar
d
ClientEvent
extends
BaseEvent
{
private
String
appId
;
private
String
appId
;
}
}
license/src/main/java/iot/sixiang/license/event/CreateForwardClientEventHandler.java
View file @
d65b2baa
...
@@ -23,7 +23,7 @@ public class CreateForwardClientEventHandler {
...
@@ -23,7 +23,7 @@ public class CreateForwardClientEventHandler {
}
}
@EventListener
@EventListener
public
void
handlerEvent
(
CreateForwarClientEvent
event
)
{
public
void
handlerEvent
(
CreateForwar
d
ClientEvent
event
)
{
String
appId
=
event
.
getAppId
();
String
appId
=
event
.
getAppId
();
Server
balanceServer
=
balanceManager
.
getBalanceServer
();
Server
balanceServer
=
balanceManager
.
getBalanceServer
();
if
(
balanceServer
!=
null
)
{
if
(
balanceServer
!=
null
)
{
...
...
license/src/main/java/iot/sixiang/license/forward/ForwardClientHandler.java
View file @
d65b2baa
...
@@ -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
());
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment