public void onOpen(Connection newConnection) { EngineConfig engineConfiguration = getEngine().getEngineConfiguration(); newConnection.setMaxBinaryMessageSize(engineConfiguration.getMaxFrameSize()); newConnection.setMaxTextMessageSize(engineConfiguration.getMaxFrameSize()); newConnection.setMaxIdleTime(engineConfiguration.getTimeout()); getEngine().onConnectionOpened(this); this.connection = newConnection; }
private void setWebsocketFactoryParameters() { websocketFactory = new WebSocketFactory(this, getEngineConfiguration().getMaxBufferSize()); websocketFactory.setMaxBinaryMessageSize(getEngineConfiguration().getMaxFrameSize()); websocketFactory.setMaxTextMessageSize(getEngineConfiguration().getMaxFrameSize()); websocketFactory.setMaxIdleTime(getEngineConfiguration().getTimeout()); }
public ChannelPipeline getPipeline() throws Exception { ChannelPipeline pipeline = Channels.pipeline(); pipeline.addLast("decoder", new HttpRequestDecoder()); pipeline.addLast("aggregator", new HttpChunkAggregator(engineConfig.getMaxFrameSize())); pipeline.addLast("encoder", new HttpResponseEncoder()); pipeline.addLast("handler", webSocketServerHandler); if (engineConfig.getTimeout() > 0) { pipeline.addLast("idleHandler", idleStateHandler); } return pipeline; } }
@SuppressWarnings("rawtypes") private void replaceListeners(ChannelHandlerContext context) { int maxFrameSize = engine.getEngineConfiguration().getMaxFrameSize(); boolean maskClientMessagePayload = true; boolean maskServerMessagePayload = false; WebsocketConnector connector = (WebsocketConnector) context.getAttachment(); String wsVersion = connector.getWebsocketVersion(); ReplayingDecoder decoder = null; OneToOneEncoder encoder = null; if (wsVersion.equals(WebsocketVersions.HYBI_13.getVersionCode())) { decoder = new WebSocket13FrameDecoder(maskClientMessagePayload, true, maxFrameSize); encoder = new WebSocket13FrameEncoder(maskServerMessagePayload); } else if (wsVersion.equals(WebsocketVersions.HYBI_10.getVersionCode())) { decoder = new WebSocket08FrameDecoder(maskClientMessagePayload, true, maxFrameSize); encoder = new WebSocket08FrameEncoder(maskServerMessagePayload); } else if (wsVersion.equals(WebsocketVersions.HIXIE_76.getVersionCode())) { decoder = new WebSocket00FrameDecoder((long) maxFrameSize); encoder = new WebSocket00FrameEncoder(); } ChannelPipeline pipeline = context.getChannel().getPipeline(); pipeline.replace("decoder", "wsDecoder", decoder); pipeline.replace("encoder", "wsEncoder", encoder); pipeline.remove("aggregator"); }