/** * Method handles Grizzly {@link Connection} close phase. Check if the {@link Connection} is a {@link WebSocket}, if * yes - tries to close the websocket gracefully (sending close frame) and calls {@link * WebSocket#onClose(DataFrame)}. If the Grizzly {@link Connection} is not websocket - passes processing to the next * filter in the chain. * * @param ctx {@link FilterChainContext} * * @return {@link NextAction} instruction for {@link FilterChain}, how it should continue the execution * * @throws java.io.IOException */ @Override public NextAction handleClose(FilterChainContext ctx) throws IOException { // Get the Connection final Connection connection = ctx.getConnection(); // check if Connection has associated WebSocket (is websocket) if (webSocketInProgress(connection)) { // if yes - get websocket final WebSocket ws = getWebSocket(connection); if (ws != null) { // if there is associated websocket object (which means handshake was passed) // close it gracefully ws.close(); } } return ctx.getInvokeAction(); }
WebSocket ws = getWebSocket(connection); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "handleRead websocket: {0} content-size={1} headers=\n{2}", if (!webSocketInProgress(connection) && !"websocket".equalsIgnoreCase(header.getUpgrade())) { return handleHandshake(ctx, message); } catch (HandshakeException e) { if (LOGGER.isLoggable(Level.FINE)) { onHandshakeFailure(connection, e);
/** * Handle Grizzly {@link Connection} write phase. If the {@link Connection} has associated {@link WebSocket} object * (websocket connection), we assume that message is websocket {@link DataFrame} and serialize it into a {@link * Buffer}. * * @param ctx {@link FilterChainContext} * * @return {@link NextAction} instruction for {@link FilterChain}, how it should continue the execution * * @throws java.io.IOException */ @Override public NextAction handleWrite(FilterChainContext ctx) throws IOException { // get the associated websocket final WebSocket websocket = getWebSocket(ctx.getConnection()); final Object msg = ctx.getMessage(); // if there is one if (websocket != null && DataFrame.isDataFrame(msg)) { final DataFrame frame = (DataFrame) msg; final WebSocketHolder holder = WebSocketHolder.get(ctx.getConnection()); final Buffer wrap = Buffers.wrap(ctx.getMemoryManager(), holder.handler.frame(frame)); ctx.setMessage(wrap); } // invoke next filter in the chain return ctx.getInvokeAction(); }
WebSocket ws = getWebSocket(connection); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "handleRead websocket: {0} content-size={1} headers=\n{2}", if (!webSocketInProgress(connection) && !"websocket".equalsIgnoreCase(header.getUpgrade())) { return handleHandshake(ctx, message); } catch (HandshakeException e) { if (LOGGER.isLoggable(Level.FINE)) { onHandshakeFailure(connection, e);
/** * Handle Grizzly {@link Connection} write phase. If the {@link Connection} has associated {@link WebSocket} object * (websocket connection), we assume that message is websocket {@link DataFrame} and serialize it into a {@link * Buffer}. * * @param ctx {@link FilterChainContext} * * @return {@link NextAction} instruction for {@link FilterChain}, how it should continue the execution * * @throws java.io.IOException */ @Override public NextAction handleWrite(FilterChainContext ctx) throws IOException { // get the associated websocket final WebSocket websocket = getWebSocket(ctx.getConnection()); final Object msg = ctx.getMessage(); // if there is one if (websocket != null && DataFrame.isDataFrame(msg)) { final DataFrame frame = (DataFrame) msg; final WebSocketHolder holder = WebSocketHolder.get(ctx.getConnection()); final Buffer wrap = Buffers.wrap(ctx.getMemoryManager(), holder.handler.frame(frame)); ctx.setMessage(wrap); } // invoke next filter in the chain return ctx.getInvokeAction(); }
WebSocket ws = getWebSocket(connection); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "handleRead websocket: {0} content-size={1} headers=\n{2}", if (!webSocketInProgress(connection) && !"websocket".equalsIgnoreCase(header.getUpgrade())) { return handleHandshake(ctx, message); } catch (HandshakeException e) { if (LOGGER.isLoggable(Level.FINE)) { onHandshakeFailure(connection, e);
/** * Method handles Grizzly {@link Connection} close phase. Check if the {@link Connection} is a {@link WebSocket}, if * yes - tries to close the websocket gracefully (sending close frame) and calls {@link * WebSocket#onClose(DataFrame)}. If the Grizzly {@link Connection} is not websocket - passes processing to the next * filter in the chain. * * @param ctx {@link FilterChainContext} * * @return {@link NextAction} instruction for {@link FilterChain}, how it should continue the execution * * @throws java.io.IOException */ @Override public NextAction handleClose(FilterChainContext ctx) throws IOException { // Get the Connection final Connection connection = ctx.getConnection(); // check if Connection has associated WebSocket (is websocket) if (webSocketInProgress(connection)) { // if yes - get websocket final WebSocket ws = getWebSocket(connection); if (ws != null) { // if there is associated websocket object (which means handshake was passed) // close it gracefully ws.close(); } } return ctx.getInvokeAction(); }
/** * Handle Grizzly {@link Connection} write phase. If the {@link Connection} has associated {@link WebSocket} object * (websocket connection), we assume that message is websocket {@link DataFrame} and serialize it into a {@link * Buffer}. * * @param ctx {@link FilterChainContext} * * @return {@link NextAction} instruction for {@link FilterChain}, how it should continue the execution * * @throws java.io.IOException */ @Override public NextAction handleWrite(FilterChainContext ctx) throws IOException { // get the associated websocket final WebSocket websocket = getWebSocket(ctx.getConnection()); final Object msg = ctx.getMessage(); // if there is one if (websocket != null && DataFrame.isDataFrame(msg)) { final DataFrame frame = (DataFrame) msg; final WebSocketHolder holder = WebSocketHolder.get(ctx.getConnection()); final Buffer wrap = Buffers.wrap(ctx.getMemoryManager(), holder.handler.frame(frame)); ctx.setMessage(wrap); } // invoke next filter in the chain return ctx.getInvokeAction(); }
WebSocket ws = getWebSocket(connection); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "handleRead websocket: {0} content-size={1} headers=\n{2}", if (!webSocketInProgress(connection) && !"websocket".equalsIgnoreCase(header.getUpgrade())) { return handleHandshake(ctx, message); } catch (HandshakeException e) { if (LOGGER.isLoggable(Level.FINE)) { onHandshakeFailure(connection, e);
/** * Method handles Grizzly {@link Connection} close phase. Check if the {@link Connection} is a {@link WebSocket}, if * yes - tries to close the websocket gracefully (sending close frame) and calls {@link * WebSocket#onClose(DataFrame)}. If the Grizzly {@link Connection} is not websocket - passes processing to the next * filter in the chain. * * @param ctx {@link FilterChainContext} * * @return {@link NextAction} instruction for {@link FilterChain}, how it should continue the execution * * @throws java.io.IOException */ @Override public NextAction handleClose(FilterChainContext ctx) throws IOException { // Get the Connection final Connection connection = ctx.getConnection(); // check if Connection has associated WebSocket (is websocket) if (webSocketInProgress(connection)) { // if yes - get websocket final WebSocket ws = getWebSocket(connection); if (ws != null) { // if there is associated websocket object (which means handshake was passed) // close it gracefully ws.close(); } } return ctx.getInvokeAction(); }
/** * Handle Grizzly {@link Connection} write phase. If the {@link Connection} has associated {@link WebSocket} object * (websocket connection), we assume that message is websocket {@link DataFrame} and serialize it into a {@link * Buffer}. * * @param ctx {@link FilterChainContext} * * @return {@link NextAction} instruction for {@link FilterChain}, how it should continue the execution * * @throws java.io.IOException */ @Override public NextAction handleWrite(FilterChainContext ctx) throws IOException { // get the associated websocket final WebSocket websocket = getWebSocket(ctx.getConnection()); final Object msg = ctx.getMessage(); // if there is one if (websocket != null && DataFrame.isDataFrame(msg)) { final DataFrame frame = (DataFrame) msg; final WebSocketHolder holder = WebSocketHolder.get(ctx.getConnection()); final Buffer wrap = Buffers.wrap(ctx.getMemoryManager(), holder.handler.frame(frame)); ctx.setMessage(wrap); } // invoke next filter in the chain return ctx.getInvokeAction(); }
WebSocket ws = getWebSocket(connection); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "handleRead websocket: {0} content-size={1} headers=\n{2}", if (!webSocketInProgress(connection) && !"websocket".equalsIgnoreCase(header.getUpgrade())) { return handleHandshake(ctx, message); } catch (HandshakeException e) { if (LOGGER.isLoggable(Level.FINE)) { onHandshakeFailure(connection, e);
/** * Method handles Grizzly {@link Connection} close phase. Check if the {@link Connection} is a {@link WebSocket}, if * yes - tries to close the websocket gracefully (sending close frame) and calls {@link * WebSocket#onClose(DataFrame)}. If the Grizzly {@link Connection} is not websocket - passes processing to the next * filter in the chain. * * @param ctx {@link FilterChainContext} * * @return {@link NextAction} instruction for {@link FilterChain}, how it should continue the execution * * @throws java.io.IOException */ @Override public NextAction handleClose(FilterChainContext ctx) throws IOException { // Get the Connection final Connection connection = ctx.getConnection(); // check if Connection has associated WebSocket (is websocket) if (webSocketInProgress(connection)) { // if yes - get websocket final WebSocket ws = getWebSocket(connection); if (ws != null) { // if there is associated websocket object (which means handshake was passed) // close it gracefully ws.close(); } } return ctx.getInvokeAction(); }
/** * Handle Grizzly {@link Connection} write phase. If the {@link Connection} has associated {@link WebSocket} object * (websocket connection), we assume that message is websocket {@link DataFrame} and serialize it into a {@link * Buffer}. * * @param ctx {@link FilterChainContext} * * @return {@link NextAction} instruction for {@link FilterChain}, how it should continue the execution * * @throws java.io.IOException */ @Override public NextAction handleWrite(FilterChainContext ctx) throws IOException { // get the associated websocket final WebSocket websocket = getWebSocket(ctx.getConnection()); final Object msg = ctx.getMessage(); // if there is one if (websocket != null && DataFrame.isDataFrame(msg)) { final DataFrame frame = (DataFrame) msg; final WebSocketHolder holder = WebSocketHolder.get(ctx.getConnection()); final Buffer wrap = Buffers.wrap(ctx.getMemoryManager(), holder.handler.frame(frame)); ctx.setMessage(wrap); } // invoke next filter in the chain return ctx.getInvokeAction(); }
WebSocket ws = getWebSocket(connection); if (LOGGER.isLoggable(Level.FINE)) { LOGGER.log(Level.FINE, "handleRead websocket: {0} content-size={1} headers=\n{2}", if (!webSocketInProgress(connection) && !"websocket".equalsIgnoreCase(header.getUpgrade())) { return handleHandshake(ctx, message); } catch (HandshakeException e) { if (LOGGER.isLoggable(Level.FINE)) { onHandshakeFailure(connection, e);
/** * Method handles Grizzly {@link Connection} close phase. Check if the {@link Connection} is a {@link WebSocket}, if * yes - tries to close the websocket gracefully (sending close frame) and calls {@link * WebSocket#onClose(DataFrame)}. If the Grizzly {@link Connection} is not websocket - passes processing to the next * filter in the chain. * * @param ctx {@link FilterChainContext} * * @return {@link NextAction} instruction for {@link FilterChain}, how it should continue the execution * * @throws java.io.IOException */ @Override public NextAction handleClose(FilterChainContext ctx) throws IOException { // Get the Connection final Connection connection = ctx.getConnection(); // check if Connection has associated WebSocket (is websocket) if (webSocketInProgress(connection)) { // if yes - get websocket final WebSocket ws = getWebSocket(connection); if (ws != null) { // if there is associated websocket object (which means handshake was passed) // close it gracefully ws.close(); } } return ctx.getInvokeAction(); }
/** * Handle Grizzly {@link Connection} write phase. If the {@link Connection} has associated {@link WebSocket} object * (websocket connection), we assume that message is websocket {@link DataFrame} and serialize it into a {@link * Buffer}. * * @param ctx {@link FilterChainContext} * * @return {@link NextAction} instruction for {@link FilterChain}, how it should continue the execution * * @throws java.io.IOException */ @Override public NextAction handleWrite(FilterChainContext ctx) throws IOException { // get the associated websocket final WebSocket websocket = getWebSocket(ctx.getConnection()); final Object msg = ctx.getMessage(); // if there is one if (websocket != null && DataFrame.isDataFrame(msg)) { final DataFrame frame = (DataFrame) msg; final WebSocketHolder holder = WebSocketHolder.get(ctx.getConnection()); final Buffer wrap = Buffers.wrap(ctx.getMemoryManager(), holder.handler.frame(frame)); ctx.setMessage(wrap); } // invoke next filter in the chain return ctx.getInvokeAction(); }
/** * Method handles Grizzly {@link Connection} close phase. Check if the {@link Connection} is a {@link WebSocket}, if * yes - tries to close the websocket gracefully (sending close frame) and calls {@link * WebSocket#onClose(DataFrame)}. If the Grizzly {@link Connection} is not websocket - passes processing to the next * filter in the chain. * * @param ctx {@link FilterChainContext} * * @return {@link NextAction} instruction for {@link FilterChain}, how it should continue the execution * * @throws java.io.IOException */ @Override public NextAction handleClose(FilterChainContext ctx) throws IOException { // Get the Connection final Connection connection = ctx.getConnection(); // check if Connection has associated WebSocket (is websocket) if (webSocketInProgress(connection)) { // if yes - get websocket final WebSocket ws = getWebSocket(connection); if (ws != null) { // if there is associated websocket object (which means handshake was passed) // close it gracefully ws.close(); } } return ctx.getInvokeAction(); }