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
aeb91d74
Commit
aeb91d74
authored
Nov 08, 2022
by
AfirSraftGarrier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
格式
parent
c6980c81
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
13 deletions
+9
-13
DeviceChannelInitializer.java
.../iot/sixiang/license/device/DeviceChannelInitializer.java
+0
-2
DeviceManager.java
...c/main/java/iot/sixiang/license/device/DeviceManager.java
+9
-11
No files found.
license/src/main/java/iot/sixiang/license/device/DeviceChannelInitializer.java
View file @
aeb91d74
...
@@ -22,12 +22,10 @@ public class DeviceChannelInitializer extends BaseChannelInitializer {
...
@@ -22,12 +22,10 @@ public class DeviceChannelInitializer extends BaseChannelInitializer {
@Override
@Override
protected
void
initChannel
(
SocketChannel
ch
)
throws
Exception
{
protected
void
initChannel
(
SocketChannel
ch
)
throws
Exception
{
// 服务端心跳检测
// 服务端心跳检测
ch
.
pipeline
().
addLast
(
new
IdleStateHandler
(
3
,
0
,
0
,
TimeUnit
.
SECONDS
));
ch
.
pipeline
().
addLast
(
new
IdleStateHandler
(
3
,
0
,
0
,
TimeUnit
.
SECONDS
));
ch
.
pipeline
().
addLast
(
"decoder"
,
new
DeviceDecoder
());
ch
.
pipeline
().
addLast
(
"decoder"
,
new
DeviceDecoder
());
ch
.
pipeline
().
addLast
(
"encoder"
,
new
DeviceEncoder
());
ch
.
pipeline
().
addLast
(
"encoder"
,
new
DeviceEncoder
());
ch
.
pipeline
().
addLast
(
workGroup
,
"handler"
,
handler
);
ch
.
pipeline
().
addLast
(
workGroup
,
"handler"
,
handler
);
}
}
}
}
license/src/main/java/iot/sixiang/license/device/DeviceManager.java
View file @
aeb91d74
...
@@ -12,16 +12,18 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -12,16 +12,18 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Component
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.PostConstruct
;
import
javax.annotation.PostConstruct
;
import
java.util.*
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
@Component
@Component
@Slf4j
@Slf4j
public
class
DeviceManager
{
public
class
DeviceManager
{
private
Map
<
String
,
SessionContext
>
sessionContexts
=
null
;
private
Map
<
String
,
SessionContext
>
sessionContexts
=
null
;
private
DeviceChannelInitializer
channelInitializer
;
private
DeviceChannelInitializer
channelInitializer
;
// private TcpServer server = null;
// private TcpServer server = null;
private
int
port
=
18889
;
private
int
port
=
18889
;
private
Map
<
String
,
DeviceVo
>
allDevice
=
null
;
private
Map
<
String
,
DeviceVo
>
allDevice
=
null
;
@Autowired
@Autowired
...
@@ -32,8 +34,8 @@ public class DeviceManager {
...
@@ -32,8 +34,8 @@ public class DeviceManager {
private
AsyncTcpServer
asyncTcpServer
;
private
AsyncTcpServer
asyncTcpServer
;
public
DeviceManager
()
{
public
DeviceManager
()
{
sessionContexts
=
new
HashMap
<
String
,
SessionContext
>();
sessionContexts
=
new
HashMap
<>();
allDevice
=
new
HashMap
<
String
,
DeviceVo
>();
allDevice
=
new
HashMap
<>();
}
}
@PostConstruct
@PostConstruct
...
@@ -44,7 +46,7 @@ public class DeviceManager {
...
@@ -44,7 +46,7 @@ public class DeviceManager {
private
void
startTcpService
()
{
private
void
startTcpService
()
{
sessionContexts
=
new
HashMap
<
String
,
SessionContext
>();
sessionContexts
=
new
HashMap
<>();
channelInitializer
=
new
DeviceChannelInitializer
(
handler
);
channelInitializer
=
new
DeviceChannelInitializer
(
handler
);
asyncTcpServer
.
start
(
port
,
channelInitializer
);
asyncTcpServer
.
start
(
port
,
channelInitializer
);
}
}
...
@@ -132,7 +134,6 @@ public class DeviceManager {
...
@@ -132,7 +134,6 @@ public class DeviceManager {
}
}
public
boolean
changeSessionOffline
(
String
channelId
)
{
public
boolean
changeSessionOffline
(
String
channelId
)
{
Iterator
<
Map
.
Entry
<
String
,
SessionContext
>>
it
=
sessionContexts
.
entrySet
().
iterator
();
Iterator
<
Map
.
Entry
<
String
,
SessionContext
>>
it
=
sessionContexts
.
entrySet
().
iterator
();
while
(
it
.
hasNext
())
{
while
(
it
.
hasNext
())
{
Map
.
Entry
<
String
,
SessionContext
>
entry
=
it
.
next
();
Map
.
Entry
<
String
,
SessionContext
>
entry
=
it
.
next
();
...
@@ -154,7 +155,6 @@ public class DeviceManager {
...
@@ -154,7 +155,6 @@ public class DeviceManager {
PageInfoModel
<
DeviceDetailVo
>
detailVoPageInfoModel
=
new
PageInfoModel
<>();
PageInfoModel
<
DeviceDetailVo
>
detailVoPageInfoModel
=
new
PageInfoModel
<>();
List
<
DeviceDetailVo
>
detailVos
=
new
ArrayList
<>();
List
<
DeviceDetailVo
>
detailVos
=
new
ArrayList
<>();
for
(
DeviceVo
vo
:
deviceVos
)
{
for
(
DeviceVo
vo
:
deviceVos
)
{
DeviceDetailVo
detailVo
=
new
DeviceDetailVo
();
DeviceDetailVo
detailVo
=
new
DeviceDetailVo
();
detailVo
.
setDeviceId
(
vo
.
getDeviceId
());
detailVo
.
setDeviceId
(
vo
.
getDeviceId
());
detailVo
.
setAppName
(
vo
.
getAppName
());
detailVo
.
setAppName
(
vo
.
getAppName
());
...
@@ -171,8 +171,6 @@ public class DeviceManager {
...
@@ -171,8 +171,6 @@ public class DeviceManager {
detailVo
.
setStatus
(
status
);
detailVo
.
setStatus
(
status
);
detailVo
.
setOnline
(
online
);
detailVo
.
setOnline
(
online
);
detailVo
.
setOffline
(
offline
);
detailVo
.
setOffline
(
offline
);
}
}
detailVos
.
add
(
detailVo
);
detailVos
.
add
(
detailVo
);
}
}
...
...
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