// 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());