@@ -49,40 +49,6 @@ public class LocalChannelInboundHandler extends SimpleChannelInboundHandler<Byte
4949
5050 private TunnelConn tunnelConn ;
5151
52- @ Override
53- public void exceptionCaught (ChannelHandlerContext ctx , Throwable cause ) throws Exception {
54- // Reject session proposal in case we are still able to and connection was stopped very early.
55- rejectProposal (context , StatusProto .fromThrowable (cause ));
56- ctx .close ();
57- super .exceptionCaught (ctx , cause );
58- }
59-
60- @ Override
61- public void channelActive (@ NotNull ChannelHandlerContext ctx ) throws Exception {
62- // Start tunnel from downstream server -> upstream TunnelService
63- tunnelConn = tunneler .tunnel (
64- context .getSessionProposal ().getSession ().getTunnelServiceAddr (),
65- context .getSessionProposal ().getSession ().getId (),
66- new TunnelHandler (logger , ctx .channel ())
67- );
68- context .tunnelConn .set (tunnelConn );
69- super .channelActive (ctx );
70- }
71-
72- @ Override
73- protected void channelRead0 (ChannelHandlerContext ctx , ByteBuf buf ) {
74- // Get underlying byte array from buf without copy
75- byte [] data = ByteBufUtil .getBytes (buf , buf .readerIndex (), buf .readableBytes (), false );
76- // downstream server -> local session server -> TunnelService
77- tunnelConn .write (data );
78- }
79-
80- @ Override
81- public void channelInactive (@ NotNull ChannelHandlerContext ctx ) throws Exception {
82- onChannelClosed (context , api , logger );
83- super .channelInactive (ctx );
84- }
85-
8652 public static void onChannelClosed (Context context ,
8753 SimpleConnectApi api ,
8854 ConnectLogger logger
@@ -96,8 +62,10 @@ public static void onChannelClosed(Context context,
9662 }
9763
9864 if (api .setPendingRemove (context .getPlayer ())) {
99- logger .translatedInfo ("connect.ingame.disconnect_name" ,
100- context .getPlayer ().getUsername ());
65+ if (!context .getPlayer ().getUsername ().isEmpty ()) { // might be just a ping request
66+ logger .translatedInfo ("connect.ingame.disconnect_name" ,
67+ context .getPlayer ().getUsername ());
68+ }
10169 }
10270
10371 Status reason = Status .newBuilder ()
@@ -120,4 +88,38 @@ static void rejectProposal(Context context, Status reason) {
12088 context .getSessionProposal ().reject (reason );
12189 }
12290 }
91+
92+ @ Override
93+ public void exceptionCaught (ChannelHandlerContext ctx , Throwable cause ) throws Exception {
94+ // Reject session proposal in case we are still able to and connection was stopped very early.
95+ rejectProposal (context , StatusProto .fromThrowable (cause ));
96+ ctx .close ();
97+ super .exceptionCaught (ctx , cause );
98+ }
99+
100+ @ Override
101+ public void channelActive (@ NotNull ChannelHandlerContext ctx ) throws Exception {
102+ // Start tunnel from downstream server -> upstream TunnelService
103+ tunnelConn = tunneler .tunnel (
104+ context .getSessionProposal ().getSession ().getTunnelServiceAddr (),
105+ context .getSessionProposal ().getSession ().getId (),
106+ new TunnelHandler (logger , ctx .channel ())
107+ );
108+ context .tunnelConn .set (tunnelConn );
109+ super .channelActive (ctx );
110+ }
111+
112+ @ Override
113+ protected void channelRead0 (ChannelHandlerContext ctx , ByteBuf buf ) {
114+ // Get underlying byte array from buf without copy
115+ byte [] data = ByteBufUtil .getBytes (buf , buf .readerIndex (), buf .readableBytes (), false );
116+ // downstream server -> local session server -> TunnelService
117+ tunnelConn .write (data );
118+ }
119+
120+ @ Override
121+ public void channelInactive (@ NotNull ChannelHandlerContext ctx ) throws Exception {
122+ onChannelClosed (context , api , logger );
123+ super .channelInactive (ctx );
124+ }
123125}
0 commit comments