@Override public void processConnect(WebSocketChannel channel, WSURI location, String[] protocols) { WebSocketHandler transportHandler = channel.transportHandler; if (useBridge(location.getURI())) { transportHandler = new WebSocketNativeBridgeHandler(); } else { transportHandler = new WebSocketNativeDelegateHandler(); } channel.transportHandler = transportHandler; transportHandler.setListener( new WebSocketHandlerListener() { @Override public void redirected(WebSocketChannel channel, String location) { listener.redirected(channel, location); } @Override public void connectionOpened(WebSocketChannel channel, String protocol) { listener.connectionOpened(channel, protocol); } @Override public void connectionFailed(WebSocketChannel channel, Exception ex) { listener.connectionFailed(channel, ex); } @Override public void connectionClosed(WebSocketChannel channel, Exception ex) { listener.connectionClosed(channel, ex); } @Override public void connectionClosed( WebSocketChannel channel, boolean wasClean, int code, String reason) { listener.connectionClosed(channel, wasClean, code, reason); } @Override public void commandMessageReceived(WebSocketChannel channel, CommandMessage message) { listener.commandMessageReceived(channel, message); } @Override public void textMessageReceived(WebSocketChannel channel, String message) { listener.textMessageReceived(channel, message); } @Override public void binaryMessageReceived(WebSocketChannel channel, WrappedByteBuffer buf) { listener.binaryMessageReceived(channel, buf); } @Override public void authenticationRequested( WebSocketChannel channel, String location, String challenge) { listener.authenticationRequested(channel, location, challenge); } }); transportHandler.processConnect(channel, location, protocols); }
@Override public void setIdleTimeout(WebSocketChannel channel, int timeout) { WebSocketHandler transportHandler = channel.transportHandler; transportHandler.setIdleTimeout(channel, timeout); }
@Override public void processBinaryMessage(WebSocketChannel channel, WrappedByteBuffer buffer) { WebSocketHandler transportHandler = channel.transportHandler; transportHandler.processBinaryMessage(channel, buffer); }
@Override public void processTextMessage(WebSocketChannel channel, String text) { WebSocketHandler transportHandler = channel.transportHandler; transportHandler.processTextMessage(channel, text); }
@Override public void processClose(WebSocketChannel channel, int code, String reason) { WebSocketHandler transportHandler = channel.transportHandler; transportHandler.processClose(channel, code, reason); }
@Override public void processAuthorize(WebSocketChannel channel, String authorizeToken) { WebSocketHandler transportHandler = channel.transportHandler; transportHandler.processAuthorize(channel, authorizeToken); }