private void websocketFrameReceived( final ChannelHandlerContext ctx, WebSocketFrame webSocketFrame) { Http.Inbound inbound = channels.get(ctx); if (webSocketFrame.isBinary()) { inbound._received(new Http.WebSocketFrame(webSocketFrame.getBinaryData().array())); } else { inbound._received(new Http.WebSocketFrame(webSocketFrame.getTextData())); } }
private void dispatchWebsocketRequest(ChannelHandlerContext ctx, WebSocketFrame frame) { WebsocketMessage wsRequest = WebsocketMessage.unmarshallFromJson(frame.getTextData()); WebsocketMessage wsResponse = null; if (wsRequest.getType().equalsIgnoreCase("PARTNER-LIST")) { wsResponse = handlePartnerListRequest(); } if (wsRequest.getType().equalsIgnoreCase("IP-EVENT-REQUEST")) { wsResponse = handleIpEventRequest(); } if (wsResponse != null) { ctx.getChannel() .write(new DefaultWebSocketFrame(WebsocketMessage.marshallToJson(wsResponse))); } }
private void handleWebSocketFrame(ChannelHandlerContext ctx, WebSocketFrame frame) { // Send the uppercased string back. ctx.getChannel().write(new DefaultWebSocketFrame(frame.getTextData().toUpperCase())); }