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
3cca62fa
Commit
3cca62fa
authored
Nov 11, 2022
by
AfirSraftGarrier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
格式并加些打印
parent
fbf04b6d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
54 additions
and
50 deletions
+54
-50
TcpServer.java
license/src/main/java/iot/sixiang/license/net/TcpServer.java
+42
-42
OperateManager.java
...main/java/iot/sixiang/license/operate/OperateManager.java
+10
-6
CommonUtil.java
...se/src/main/java/iot/sixiang/license/util/CommonUtil.java
+2
-2
No files found.
license/src/main/java/iot/sixiang/license/net/TcpServer.java
View file @
3cca62fa
...
...
@@ -11,48 +11,48 @@ import lombok.extern.slf4j.Slf4j;
@Slf4j
public
class
TcpServer
{
private
int
port
;
private
BaseChannelInitializer
channelInitializer
;
private
int
port
;
private
BaseChannelInitializer
channelInitializer
;
public
TcpServer
(
int
port
,
BaseChannelInitializer
channelInitializer
)
{
this
.
port
=
port
;
this
.
channelInitializer
=
channelInitializer
;
}
public
TcpServer
(
int
port
,
BaseChannelInitializer
channelInitializer
)
{
this
.
port
=
port
;
this
.
channelInitializer
=
channelInitializer
;
}
public
void
start
()
{
Thread
thread
=
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
//创建两个线程组 bossGroup、workerGroup
EventLoopGroup
bossGroup
=
new
NioEventLoopGroup
(
4
);
EventLoopGroup
workerGroup
=
new
NioEventLoopGroup
(
4
);
log
.
debug
(
"Tcp服务,开始监听端口:{}"
,
port
);
//创建服务端的启动对象,设置参数
ServerBootstrap
b
=
new
ServerBootstrap
();
//设置两个线程组boosGroup和workerGroup
b
.
group
(
bossGroup
,
workerGroup
)
//设置服务端通道实现类型
.
channel
(
NioServerSocketChannel
.
class
)
// .handler(new LoggingHandler(LogLevel.INFO))
.
childHandler
(
channelInitializer
)
// 设置tcp缓冲区
.
option
(
ChannelOption
.
SO_BACKLOG
,
1024
)
//设置保持活动连接状态
.
childOption
(
ChannelOption
.
SO_KEEPALIVE
,
true
);
ChannelFuture
f
;
try
{
f
=
b
.
bind
(
port
).
sync
();
f
.
channel
().
closeFuture
().
sync
();
}
catch
(
InterruptedException
e
)
{
// TODO Auto-generated catch block
log
.
error
(
"Tcp服务异常,端口:{}"
,
port
);
}
finally
{
log
.
debug
(
"Tcp服务,停止退出"
);
workerGroup
.
shutdownGracefully
();
bossGroup
.
shutdownGracefully
();
}
}
});
thread
.
start
();
}
public
void
start
()
{
Thread
thread
=
new
Thread
(
new
Runnable
()
{
@Override
public
void
run
()
{
//创建两个线程组 bossGroup、workerGroup
EventLoopGroup
bossGroup
=
new
NioEventLoopGroup
(
4
);
EventLoopGroup
workerGroup
=
new
NioEventLoopGroup
(
4
);
log
.
debug
(
"Tcp服务,开始监听端口:{}"
,
port
);
//创建服务端的启动对象,设置参数
ServerBootstrap
b
=
new
ServerBootstrap
();
//设置两个线程组boosGroup和workerGroup
b
.
group
(
bossGroup
,
workerGroup
)
//设置服务端通道实现类型
.
channel
(
NioServerSocketChannel
.
class
)
// .handler(new LoggingHandler(LogLevel.INFO))
.
childHandler
(
channelInitializer
)
// 设置tcp缓冲区
.
option
(
ChannelOption
.
SO_BACKLOG
,
1024
)
//设置保持活动连接状态
.
childOption
(
ChannelOption
.
SO_KEEPALIVE
,
true
);
ChannelFuture
f
;
try
{
f
=
b
.
bind
(
port
).
sync
();
f
.
channel
().
closeFuture
().
sync
();
}
catch
(
InterruptedException
e
)
{
// TODO Auto-generated catch block
log
.
error
(
"Tcp服务异常,端口:{}"
,
port
);
}
finally
{
log
.
debug
(
"Tcp服务,停止退出"
);
workerGroup
.
shutdownGracefully
();
bossGroup
.
shutdownGracefully
();
}
}
});
thread
.
start
();
}
}
license/src/main/java/iot/sixiang/license/operate/OperateManager.java
View file @
3cca62fa
...
...
@@ -8,7 +8,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Component
;
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
@Slf4j
...
...
@@ -43,7 +47,7 @@ public class OperateManager {
return
result
;
}
public
int
getCount
(){
public
int
getCount
()
{
return
this
.
count
;
}
...
...
@@ -69,8 +73,8 @@ public class OperateManager {
this
.
putSamMonitorMap
(
serverIp
,
samMonitor
);
}
// createProxyClient();
// test();
// createProxyClient();
// test();
}
...
...
@@ -89,8 +93,8 @@ public class OperateManager {
private
void
test
()
{
String
serverIp
=
"192.168.1.56"
;
int
port
=
18889
;
// serverIp = "172.17.115.81";
// port = 777;
// serverIp = "172.17.115.81";
// port = 777;
this
.
startTcpClient
(
serverIp
,
port
);
}
...
...
license/src/main/java/iot/sixiang/license/util/CommonUtil.java
View file @
3cca62fa
...
...
@@ -87,9 +87,9 @@ public class CommonUtil {
String
serverParentDirectory
=
getServerParentDirectory
();
if
(
os
!=
null
)
{
if
(
os
.
toLowerCase
(
Locale
.
ENGLISH
).
startsWith
(
"win"
))
{
return
serverParentDirectory
+
File
.
separator
+
"li
b
"
+
File
.
separator
+
fileName
+
".dll"
;
return
serverParentDirectory
+
File
.
separator
+
"li
cense/file/libs
"
+
File
.
separator
+
fileName
+
".dll"
;
}
else
{
return
serverParentDirectory
+
File
.
separator
+
"li
b
"
+
File
.
separator
+
fileName
+
".so"
;
return
serverParentDirectory
+
File
.
separator
+
"li
cense/file/libs
"
+
File
.
separator
+
fileName
+
".so"
;
}
}
return
""
;
...
...
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