mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-02-14 18:10:05 +00:00
Several minor improvments to websockets
- Fire close events instead of failure when open websockets error. - Handle ping events. I thought I was doing this already, but this requires a WebsocketProtocolHandler. Fixes #118
This commit is contained in:
parent
18d468e887
commit
9f2884bc0f
@ -83,6 +83,11 @@ public class WebsocketHandler extends SimpleChannelInboundHandler<Object>
|
|||||||
CloseWebSocketFrame closeFrame = (CloseWebSocketFrame) frame;
|
CloseWebSocketFrame closeFrame = (CloseWebSocketFrame) frame;
|
||||||
websocket.close( closeFrame.statusCode(), closeFrame.reasonText() );
|
websocket.close( closeFrame.statusCode(), closeFrame.reasonText() );
|
||||||
}
|
}
|
||||||
|
else if( frame instanceof PingWebSocketFrame )
|
||||||
|
{
|
||||||
|
frame.content().retain();
|
||||||
|
ctx.channel().writeAndFlush( new PongWebSocketFrame( frame.content() ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -108,6 +113,13 @@ public class WebsocketHandler extends SimpleChannelInboundHandler<Object>
|
|||||||
message = "Could not connect";
|
message = "Could not connect";
|
||||||
}
|
}
|
||||||
|
|
||||||
websocket.failure( message );
|
if( handshaker.isHandshakeComplete() )
|
||||||
|
{
|
||||||
|
websocket.close( -1, message );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
websocket.failure( message );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user