mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 11:39:11 +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.Client;
|
||||||
import pro.gravit.launchserver.socket.NettyConnectContext;
|
import pro.gravit.launchserver.socket.NettyConnectContext;
|
||||||
import pro.gravit.launchserver.socket.WebSocketService;
|
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.IOHelper;
|
||||||
import pro.gravit.utils.helper.LogHelper;
|
import pro.gravit.utils.helper.LogHelper;
|
||||||
|
|
||||||
|
@ -22,6 +24,7 @@ public class WebSocketFrameHandler extends SimpleChannelInboundHandler<WebSocket
|
||||||
public final WebSocketService service;
|
public final WebSocketService service;
|
||||||
private final UUID connectUUID = UUID.randomUUID();
|
private final UUID connectUUID = UUID.randomUUID();
|
||||||
public NettyConnectContext context;
|
public NettyConnectContext context;
|
||||||
|
public BiHookSet<ChannelHandlerContext, WebSocketFrame> hooks = new BiHookSet<>();
|
||||||
private Client client;
|
private Client client;
|
||||||
|
|
||||||
public WebSocketFrameHandler(NettyConnectContext context, LaunchServer srv, WebSocketService service) {
|
public WebSocketFrameHandler(NettyConnectContext context, LaunchServer srv, WebSocketService service) {
|
||||||
|
@ -58,6 +61,7 @@ public void channelActive(ChannelHandlerContext ctx) {
|
||||||
@Override
|
@Override
|
||||||
protected void channelRead0(ChannelHandlerContext ctx, WebSocketFrame frame) {
|
protected void channelRead0(ChannelHandlerContext ctx, WebSocketFrame frame) {
|
||||||
// ping and pong frames already handled
|
// ping and pong frames already handled
|
||||||
|
if(hooks.hook(ctx, frame)) return;
|
||||||
if (frame instanceof TextWebSocketFrame) {
|
if (frame instanceof TextWebSocketFrame) {
|
||||||
service.process(ctx, (TextWebSocketFrame) frame, client, context.ip);
|
service.process(ctx, (TextWebSocketFrame) frame, client, context.ip);
|
||||||
} else if ((frame instanceof PingWebSocketFrame)) {
|
} else if ((frame instanceof PingWebSocketFrame)) {
|
||||||
|
|
Loading…
Reference in a new issue