public SockJsConfig config() { return service.config(); }
private void handleWebSocketFrame(final ChannelHandlerContext ctx, final WebSocketFrame wsFrame) throws Exception { if (wsFrame instanceof CloseWebSocketFrame) { wsFrame.retain(); service.onClose(); handshaker.close(ctx.channel(), (CloseWebSocketFrame) wsFrame); return; } if (wsFrame instanceof PingWebSocketFrame) { wsFrame.content().retain(); ctx.channel().writeAndFlush(new PongWebSocketFrame(wsFrame.content())); return; } if (!(wsFrame instanceof TextWebSocketFrame)) { throw new UnsupportedOperationException(String.format("%s frame types not supported", wsFrame.getClass().getName())); } final String message = ((TextWebSocketFrame) wsFrame).text(); service.onMessage(message); }
@Override public void operationComplete(final ChannelFuture future) throws Exception { if (future.isSuccess()) { ctx.pipeline().remove(SockJsHandler.class); ctx.pipeline().remove(CorsInboundHandler.class); ctx.pipeline().remove(CorsOutboundHandler.class); ctx.pipeline().addLast(new RawWebSocketSendHandler()); service.onOpen(new SockJsSessionContext() { @Override public void send(String message) { ctx.writeAndFlush(new TextWebSocketFrame(message)); } @Override public void close() { ctx.close(); } @Override public ChannelHandlerContext getContext() { return ctx; } }); } } });
public void onClose() { setState(State.CLOSED); service.onClose(); }
public void onMessage(final String message) throws Exception { service.onMessage(message); updateTimestamp(); }
private void handleWebSocketFrame(final ChannelHandlerContext ctx, final WebSocketFrame wsFrame) throws Exception { if (wsFrame instanceof CloseWebSocketFrame) { wsFrame.retain(); service.onClose(); handshaker.close(ctx.channel(), (CloseWebSocketFrame) wsFrame); return; } if (wsFrame instanceof PingWebSocketFrame) { wsFrame.content().retain(); ctx.channel().writeAndFlush(new PongWebSocketFrame(wsFrame.content())); return; } if (!(wsFrame instanceof TextWebSocketFrame)) { throw new UnsupportedOperationException(String.format("%s frame types not supported", wsFrame.getClass().getName())); } final String message = ((TextWebSocketFrame) wsFrame).text(); service.onMessage(message); }
@Override public void operationComplete(final ChannelFuture future) throws Exception { if (future.isSuccess()) { ctx.pipeline().remove(SockJsHandler.class); ctx.pipeline().remove(CorsInboundHandler.class); ctx.pipeline().remove(CorsOutboundHandler.class); ctx.pipeline().addLast(new RawWebSocketSendHandler()); service.onOpen(new SockJsSessionContext() { @Override public void send(String message) { ctx.writeAndFlush(new TextWebSocketFrame(message)); } @Override public void close() { ctx.close(); } @Override public ChannelHandlerContext getContext() { return ctx; } }); } } });
public void onClose() { setState(State.CLOSED); service.onClose(); }
public void onMessage(final String message) throws Exception { service.onMessage(message); updateTimestamp(); }
public void onOpen(final SockJsSessionContext session) { setState(State.OPEN); service.onOpen(session); updateTimestamp(); }
public SockJsConfig config() { return service.config(); }
public void onOpen(final SockJsSessionContext session) { setState(State.OPEN); service.onOpen(session); updateTimestamp(); }