Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
GnssServer
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
zhushanglei
GnssServer
Commits
b304dbc0
Commit
b304dbc0
authored
May 07, 2022
by
zhushanglei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
gps数据采集修改
parent
538382b3
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
9 deletions
+14
-9
TcpServer.java
src/main/java/server/TcpServer.java
+3
-3
TcpServerHandler.java
src/main/java/server/TcpServerHandler.java
+8
-3
config.properties
src/main/resources/config.properties
+3
-3
No files found.
src/main/java/server/TcpServer.java
View file @
b304dbc0
...
@@ -28,8 +28,8 @@ public class TcpServer {
...
@@ -28,8 +28,8 @@ public class TcpServer {
// 服务器地址端口
// 服务器地址端口
// private static final String IP = "192.168.0.112";
// private static final String IP = "192.168.0.112";
// private static final String IP = "192.168.0.107";
// private static final String IP = "192.168.0.107";
public
static
String
IP
=
"127.0.0.1
"
;
// public static String IP = "8.143.203.103
";
private
static
final
int
PORT
=
9
200
;
private
static
final
int
PORT
=
9
093
;
...
@@ -70,7 +70,7 @@ public class TcpServer {
...
@@ -70,7 +70,7 @@ public class TcpServer {
}
}
});
});
// 异步绑定端口
// 异步绑定端口
b
.
bind
(
IP
,
PORT
).
sync
();
b
.
bind
(
PORT
).
sync
();
logger
.
info
(
"TCP Server Started"
);
logger
.
info
(
"TCP Server Started"
);
}
}
// 关闭端口
// 关闭端口
...
...
src/main/java/server/TcpServerHandler.java
View file @
b304dbc0
...
@@ -30,7 +30,7 @@ public class TcpServerHandler extends SimpleChannelInboundHandler<Object> {
...
@@ -30,7 +30,7 @@ public class TcpServerHandler extends SimpleChannelInboundHandler<Object> {
// public static String serverUrl;
// public static String serverUrl;
//全局变量
//全局变量
Map
<
String
,
ChannelHandlerContext
>
gpsServerContextHashMap
=
new
HashMap
<>();
private
static
Map
<
String
,
ChannelHandlerContext
>
gpsServerContextHashMap
=
new
HashMap
<>();
//获取全局变量信息
//获取全局变量信息
public
ChannelHandlerContext
getContext
(
String
key
){
public
ChannelHandlerContext
getContext
(
String
key
){
return
gpsServerContextHashMap
.
get
(
key
);
return
gpsServerContextHashMap
.
get
(
key
);
...
@@ -53,11 +53,16 @@ public class TcpServerHandler extends SimpleChannelInboundHandler<Object> {
...
@@ -53,11 +53,16 @@ public class TcpServerHandler extends SimpleChannelInboundHandler<Object> {
protected
void
channelRead0
(
ChannelHandlerContext
ctx
,
Object
msg
)
throws
Exception
{
protected
void
channelRead0
(
ChannelHandlerContext
ctx
,
Object
msg
)
throws
Exception
{
// logger.info("**接收到的基站数据<<start:" + msg.toString() +">>end");
// logger.info("**接收到的基站数据<<start:" + msg.toString() +">>end");
if
(
TcpClient
.
client
.
equalsIgnoreCase
(
msg
.
toString
())){
//移动站
if
(
TcpClient
.
client
.
equalsIgnoreCase
(
msg
.
toString
())){
//移动站
String
clinetIp
=
((
InetSocketAddress
)
ctx
.
channel
().
remoteAddress
()).
getAddress
().
getHostAddress
();
String
clinetIp
=
((
InetSocketAddress
)
ctx
.
channel
().
remoteAddress
()).
getAddress
().
getHostAddress
()
+
ctx
.
channel
().
id
();
logger
.
warn
(
"移动站IP:"
+
clinetIp
);
addContext
(
clinetIp
,
ctx
);
addContext
(
clinetIp
,
ctx
);
// ctx.writeAndFlush("你好"); //TextWebSocketFrame
logger
.
warn
(
"if>>hashmap移动站:"
+
gpsServerContextHashMap
);
ctx
.
writeAndFlush
(
"OK!!"
);
//TextWebSocketFrame
}
else
{
//基站
}
else
{
//基站
logger
.
info
(
"else>>基站:"
+
msg
.
toString
());
logger
.
info
(
"else>>hashmap基站:"
+
gpsServerContextHashMap
);
gpsServerContextHashMap
.
forEach
((
k
,
v
)->{
gpsServerContextHashMap
.
forEach
((
k
,
v
)->{
logger
.
error
(
"基站发送给移动站:"
+
msg
.
toString
());
v
.
writeAndFlush
(
msg
.
toString
());
v
.
writeAndFlush
(
msg
.
toString
());
});
});
}
}
...
...
src/main/resources/config.properties
View file @
b304dbc0
serverUrl
:
http://192.168.0.111:8001/gps
serverUrl
:
http://8.143.203.103:9090/gps
gpsServerIP
:
127.0.0.1
gpsServerIP
:
8.143.203.103
gpsServerPort
:
9200
gpsServerPort
:
9093
\ No newline at end of file
\ No newline at end of file
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