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
c87f5c71
Commit
c87f5c71
authored
Nov 08, 2022
by
AfirSraftGarrier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
格式
parent
176c9dcb
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
7 additions
and
38 deletions
+7
-38
DeviceProtocol.java
.../main/java/iot/sixiang/license/device/DeviceProtocol.java
+2
-2
DeviceServerHandler.java
.../java/iot/sixiang/license/device/DeviceServerHandler.java
+2
-3
CreateForwarClientEventHandler.java
...sixiang/license/event/CreateForwarClientEventHandler.java
+1
-10
CreateForwardClientEvent.java
...a/iot/sixiang/license/event/CreateForwardClientEvent.java
+1
-2
EventPublisher.java
...c/main/java/iot/sixiang/license/event/EventPublisher.java
+0
-4
ForwardClientRequestEvent.java
.../iot/sixiang/license/event/ForwardClientRequestEvent.java
+0
-2
ForwardClientRequestEventHandler.java
...xiang/license/event/ForwardClientRequestEventHandler.java
+0
-4
ForwardClient.java
.../main/java/iot/sixiang/license/forward/ForwardClient.java
+1
-6
TcpClient.java
license/src/main/java/iot/sixiang/license/net/TcpClient.java
+0
-5
No files found.
license/src/main/java/iot/sixiang/license/device/DeviceProtocol.java
View file @
c87f5c71
...
...
@@ -5,7 +5,7 @@ import lombok.Data;
@Data
public
class
DeviceProtocol
{
// |STX |LEN |CMD |ACK |DATA |END
// |STX |LEN |CMD |ACK |DATA |END
private
short
stx
;
//
private
int
len
;
//
...
...
@@ -15,7 +15,7 @@ public class DeviceProtocol {
private
byte
[]
content
;
// 数据
private
byte
end
;
public
DeviceProtocol
(
short
stx
,
int
len
,
byte
cmd
,
byte
ack
,
byte
[]
content
,
byte
end
)
{
public
DeviceProtocol
(
short
stx
,
int
len
,
byte
cmd
,
byte
ack
,
byte
[]
content
,
byte
end
)
{
super
();
this
.
stx
=
stx
;
this
.
len
=
len
;
...
...
license/src/main/java/iot/sixiang/license/device/DeviceServerHandler.java
View file @
c87f5c71
...
...
@@ -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.CreateForwar
d
ClientEvent
;
import
iot.sixiang.license.event.DeviceClientInactiveEvent
;
import
iot.sixiang.license.event.EventPublisher
;
import
iot.sixiang.license.event.ForwardClientRequestEvent
;
...
...
@@ -27,7 +27,6 @@ import java.net.InetSocketAddress;
@ChannelHandler
.
Sharable
@Slf4j
public
class
DeviceServerHandler
extends
SimpleChannelInboundHandler
<
Object
>
{
@Autowired
EventPublisher
eventPublisher
;
...
...
@@ -139,7 +138,7 @@ public class DeviceServerHandler extends SimpleChannelInboundHandler<Object> {
deviceManager
.
putSession
(
appId
,
session
);
// TODO 创建透传的客户端
CreateForwar
ClientEvent
event
=
new
CreateForwar
ClientEvent
();
CreateForwar
dClientEvent
event
=
new
CreateForward
ClientEvent
();
event
.
setAppId
(
appId
);
eventPublisher
.
publishEvent
(
event
);
}
...
...
license/src/main/java/iot/sixiang/license/event/CreateForwarClientEventHandler.java
View file @
c87f5c71
...
...
@@ -11,8 +11,6 @@ import org.springframework.stereotype.Component;
@Component
@Slf4j
public
class
CreateForwarClientEventHandler
{
@Autowired
ForwardManager
forwardManager
;
@Autowired
...
...
@@ -20,14 +18,11 @@ public class CreateForwarClientEventHandler {
@Autowired
BalanceManager
balanceManager
;
public
CreateForwarClientEventHandler
()
{
}
@EventListener
public
void
handlerEvent
(
CreateForwarClientEvent
event
)
{
public
void
handlerEvent
(
CreateForwardClientEvent
event
)
{
String
appId
=
event
.
getAppId
();
Server
balanceServer
=
balanceManager
.
getBalanceServer
();
...
...
@@ -38,9 +33,5 @@ public class CreateForwarClientEventHandler {
}
else
{
log
.
error
(
"balanceServer is null"
);
}
}
}
license/src/main/java/iot/sixiang/license/event/CreateForwarClientEvent.java
→
license/src/main/java/iot/sixiang/license/event/CreateForwar
d
ClientEvent.java
View file @
c87f5c71
...
...
@@ -5,7 +5,6 @@ package iot.sixiang.license.event;
import
lombok.Data
;
@Data
public
class
CreateForwarClientEvent
extends
BaseEvent
{
public
class
CreateForwar
d
ClientEvent
extends
BaseEvent
{
private
String
appId
;
}
license/src/main/java/iot/sixiang/license/event/EventPublisher.java
View file @
c87f5c71
package
iot
.
sixiang
.
license
.
event
;
import
lombok.extern.slf4j.Slf4j
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.ApplicationEventPublisher
;
import
org.springframework.context.annotation.DependsOn
;
import
org.springframework.stereotype.Component
;
@Component
@Slf4j
public
class
EventPublisher
{
@Autowired
private
ApplicationEventPublisher
applicationEventPublisher
;
...
...
license/src/main/java/iot/sixiang/license/event/ForwardClientRequestEvent.java
View file @
c87f5c71
package
iot
.
sixiang
.
license
.
event
;
import
io.netty.channel.socket.SocketChannel
;
import
iot.sixiang.license.device.DeviceProtocol
;
import
lombok.Data
;
...
...
@@ -9,5 +8,4 @@ public class ForwardClientRequestEvent extends BaseEvent {
private
String
appId
;
private
String
deviceChannelId
;
private
DeviceProtocol
protocol
;
}
\ No newline at end of file
license/src/main/java/iot/sixiang/license/event/ForwardClientRequestEventHandler.java
View file @
c87f5c71
...
...
@@ -22,7 +22,6 @@ public class ForwardClientRequestEventHandler {
public
ForwardClientRequestEventHandler
()
{
}
@EventListener
...
...
@@ -37,8 +36,5 @@ public class ForwardClientRequestEventHandler {
log
.
debug
(
"forward client request:"
+
appId
+
","
+
forwardSessionContext
);
SocketChannel
clientChannel
=
forwardSessionContext
.
getClientChannel
();
clientChannel
.
writeAndFlush
(
protocol
);
}
}
license/src/main/java/iot/sixiang/license/forward/ForwardClient.java
View file @
c87f5c71
...
...
@@ -15,8 +15,6 @@ import javax.annotation.PostConstruct;
@Component
@Slf4j
public
class
ForwardClient
{
private
TcpClient
client
=
null
;
private
ForwardChannelInitializer
channelInitializer
;
private
Bootstrap
bootstrap
;
...
...
@@ -25,11 +23,10 @@ public class ForwardClient {
ForwardClientHandler
handler
;
public
ForwardClient
()
{
}
@PostConstruct
public
void
init
(){
public
void
init
()
{
channelInitializer
=
new
ForwardChannelInitializer
(
handler
);
EventLoopGroup
eventLoopGroup
=
new
NioEventLoopGroup
();
bootstrap
=
new
Bootstrap
();
...
...
@@ -42,7 +39,6 @@ public class ForwardClient {
}
catch
(
IllegalStateException
ex
)
{
log
.
error
(
ex
.
getMessage
());
}
}
public
void
startTcp
(
String
host
,
int
port
,
String
appId
)
{
...
...
@@ -54,5 +50,4 @@ public class ForwardClient {
client
=
new
TcpClient
(
host
,
port
,
channelInitializer
,
listener
,
bootstrap
);
client
.
start
();
}
}
license/src/main/java/iot/sixiang/license/net/TcpClient.java
View file @
c87f5c71
...
...
@@ -21,12 +21,7 @@ public class TcpClient {
}
public
void
start
()
{
ChannelFuture
future
=
bootstrap
.
connect
(
host
,
port
);
future
.
addListener
(
connectionListener
);
}
}
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