Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
E
echo-lib-Deprecated
Project
Project
Details
Activity
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
echo
echo-lib-Deprecated
Commits
edd0cf99
Commit
edd0cf99
authored
Aug 07, 2020
by
Administrator
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
handle message TYPE_DESTROY
parent
cb3842eb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
1 deletion
+14
-1
EchoClientChannelHandler.java
.../com/virjar/echo/nat/client/EchoClientChannelHandler.java
+11
-0
PacketCommon.java
src/main/java/com/virjar/echo/nat/protocol/PacketCommon.java
+3
-1
No files found.
src/main/java/com/virjar/echo/nat/client/EchoClientChannelHandler.java
View file @
edd0cf99
...
@@ -41,6 +41,10 @@ public class EchoClientChannelHandler extends SimpleChannelInboundHandler<EchoPa
...
@@ -41,6 +41,10 @@ public class EchoClientChannelHandler extends SimpleChannelInboundHandler<EchoPa
case
PacketCommon
.
C_TYPE_CONTROL
:
case
PacketCommon
.
C_TYPE_CONTROL
:
handleControlMessage
(
ctx
,
msg
);
handleControlMessage
(
ctx
,
msg
);
break
;
break
;
case
PacketCommon
.
TYPE_DESTROY
:
handleDestroyMessage
(
ctx
);
break
;
default
:
default
:
EchoLogger
.
getLogger
().
warn
(
"Unknown message type:"
+
msg
.
getType
());
EchoLogger
.
getLogger
().
warn
(
"Unknown message type:"
+
msg
.
getType
());
break
;
break
;
...
@@ -48,6 +52,10 @@ public class EchoClientChannelHandler extends SimpleChannelInboundHandler<EchoPa
...
@@ -48,6 +52,10 @@ public class EchoClientChannelHandler extends SimpleChannelInboundHandler<EchoPa
}
}
private
void
handleDestroyMessage
(
ChannelHandlerContext
ctx
)
{
ctx
.
close
();
}
private
void
handleControlMessage
(
ChannelHandlerContext
ctx
,
EchoPacket
msg
)
{
private
void
handleControlMessage
(
ChannelHandlerContext
ctx
,
EchoPacket
msg
)
{
long
seq
=
msg
.
getSerialNumber
();
long
seq
=
msg
.
getSerialNumber
();
String
action
=
msg
.
getExtra
();
String
action
=
msg
.
getExtra
();
...
@@ -163,6 +171,9 @@ public class EchoClientChannelHandler extends SimpleChannelInboundHandler<EchoPa
...
@@ -163,6 +171,9 @@ public class EchoClientChannelHandler extends SimpleChannelInboundHandler<EchoPa
@Override
@Override
public
void
channelInactive
(
ChannelHandlerContext
ctx
)
throws
Exception
{
public
void
channelInactive
(
ChannelHandlerContext
ctx
)
throws
Exception
{
super
.
channelInactive
(
ctx
);
super
.
channelInactive
(
ctx
);
if
(
echoClient
.
isAlive
())
{
return
;
}
EchoLogger
.
getLogger
().
warn
(
"client disconnected: "
+
ctx
.
channel
()
+
" prepare to reconnect"
);
EchoLogger
.
getLogger
().
warn
(
"client disconnected: "
+
ctx
.
channel
()
+
" prepare to reconnect"
);
ctx
.
executor
().
schedule
(
new
Runnable
()
{
ctx
.
executor
().
schedule
(
new
Runnable
()
{
@Override
@Override
...
...
src/main/java/com/virjar/echo/nat/protocol/PacketCommon.java
View file @
edd0cf99
...
@@ -40,6 +40,8 @@ public class PacketCommon {
...
@@ -40,6 +40,8 @@ public class PacketCommon {
return
"C_TYPE_CONTROL"
;
return
"C_TYPE_CONTROL"
;
case
TYPE_CONNECT_READY:
case
TYPE_CONNECT_READY:
return
"TYPE_CONNECT_READY"
;
return
"TYPE_CONNECT_READY"
;
case
TYPE_DESTROY:
return
"TYPE_DESTROY"
;
default
:
default
:
return
"UNKNOWN"
;
return
"UNKNOWN"
;
}
}
...
@@ -84,5 +86,5 @@ public class PacketCommon {
...
@@ -84,5 +86,5 @@ public class PacketCommon {
public
static
final
byte
TYPE_CONNECT_READY
=
0x07
;
public
static
final
byte
TYPE_CONNECT_READY
=
0x07
;
// 销毁隧道
// 销毁隧道
public
static
final
byte
TYPE_DESTRO
T
=
0x08
;
public
static
final
byte
TYPE_DESTRO
Y
=
0x08
;
}
}
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