});
}
}
private void handleWebSocketFrame(final ChannelHandlerContext ctx, final MessageEvent messageEvent) throws URISyntaxException, IOException {
WebSocketFrame frame = (WebSocketFrame) messageEvent.getMessage();
// Check for closing frame
if (frame instanceof CloseWebSocketFrame) {
ctx.getChannel().write(frame).addListener(ChannelFutureListener.CLOSE);
} else if (frame instanceof PingWebSocketFrame) {
ctx.getChannel().write(new PongWebSocketFrame(frame.getBinaryData()));
} else if (frame instanceof BinaryWebSocketFrame) {
ChannelBuffer binaryData = frame.getBinaryData();
webSocketProcessor.invokeWebSocketProtocol((WebSocket) ctx.getAttachment(), binaryData.array(), binaryData.arrayOffset(), binaryData.readableBytes());
} else if (frame instanceof TextWebSocketFrame) {
webSocketProcessor.invokeWebSocketProtocol((WebSocket) ctx.getAttachment(), ((TextWebSocketFrame) frame).getText());
} else if (frame instanceof PongWebSocketFrame) {
if (config.enablePong()) {
ctx.getChannel().write(new PingWebSocketFrame(frame.getBinaryData()));
} else {
logger.trace("Received Pong Frame on Channel {}", ctx.getChannel());
}
} else {
logger.warn("{} frame types not supported", frame.getClass());
ctx.getChannel().close();
}
}