mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +03:00
[FEATURE] Raw WebSocketFrame API
This commit is contained in:
parent
ea5449a196
commit
fe21427d17
1 changed files with 4 additions and 0 deletions
|
@ -8,6 +8,8 @@
|
|||
import pro.gravit.launchserver.socket.Client;
|
||||
import pro.gravit.launchserver.socket.NettyConnectContext;
|
||||
import pro.gravit.launchserver.socket.WebSocketService;
|
||||
import pro.gravit.utils.BiHookSet;
|
||||
import pro.gravit.utils.HookSet;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
|
@ -22,6 +24,7 @@ public class WebSocketFrameHandler extends SimpleChannelInboundHandler<WebSocket
|
|||
public final WebSocketService service;
|
||||
private final UUID connectUUID = UUID.randomUUID();
|
||||
public NettyConnectContext context;
|
||||
public BiHookSet<ChannelHandlerContext, WebSocketFrame> hooks = new BiHookSet<>();
|
||||
private Client client;
|
||||
|
||||
public WebSocketFrameHandler(NettyConnectContext context, LaunchServer srv, WebSocketService service) {
|
||||
|
@ -58,6 +61,7 @@ public void channelActive(ChannelHandlerContext ctx) {
|
|||
@Override
|
||||
protected void channelRead0(ChannelHandlerContext ctx, WebSocketFrame frame) {
|
||||
// ping and pong frames already handled
|
||||
if(hooks.hook(ctx, frame)) return;
|
||||
if (frame instanceof TextWebSocketFrame) {
|
||||
service.process(ctx, (TextWebSocketFrame) frame, client, context.ip);
|
||||
} else if ((frame instanceof PingWebSocketFrame)) {
|
||||
|
|
Loading…
Reference in a new issue