@Override protected void initChannel(final SocketChannel socketChannel) throws Exception { final ChannelPipeline pipeline = socketChannel.pipeline(); if (sockjsConfig.isTls()) { final SSLEngine engine = sslContext.createSSLEngine(); engine.setUseClientMode(false); pipeline.addLast(new SslHandler(engine)); } pipeline.addLast(new HttpServerCodec()); pipeline.addLast(new HttpObjectAggregator(65536)); final DefaultSimplePushServer simplePushServer = new DefaultSimplePushServer(datastore, simplePushConfig, privateKey); pipeline.addLast(new NotificationHandler(simplePushServer)); pipeline.addLast(new CorsInboundHandler()); pipeline.addLast(new SockJsHandler(new SimplePushServiceFactory(sockjsConfig, simplePushServer))); pipeline.addLast(backgroundGroup, new UserAgentReaperHandler(simplePushServer)); pipeline.addLast(new CorsOutboundHandler()); }
@Override protected void initChannel(final SocketChannel socketChannel) throws Exception { final ChannelPipeline pipeline = socketChannel.pipeline(); if (sockjsConfig.isTls()) { final SSLEngine engine = sslContext.createSSLEngine(); engine.setUseClientMode(false); pipeline.addLast(new SslHandler(engine)); } pipeline.addLast(new HttpServerCodec()); pipeline.addLast(new HttpObjectAggregator(65536)); final DefaultSimplePushServer simplePushServer = new DefaultSimplePushServer(datastore, simplePushConfig, privateKey); pipeline.addLast(new NotificationHandler(simplePushServer)); pipeline.addLast(new CorsInboundHandler()); pipeline.addLast(new SockJsHandler(new SimplePushServiceFactory(sockjsConfig, simplePushServer))); pipeline.addLast(backgroundGroup, new UserAgentReaperHandler(simplePushServer)); pipeline.addLast(new CorsOutboundHandler()); }
/** * Sole constructor. * * @param simplePushConfig the {@link SimplePushServerConfig} configuration. * @param datastore the {@link DataStore} to be passed to the {@link SimplePushServiceFactory}. * @param sockjsConfig the SockJS {@link SimplePushServerConfig}. * @param backgroundGroup an {@link EventExecutorGroup} to be used for the {@link UserAgentReaperHandler}. */ public SockJSChannelInitializer(final SimplePushServerConfig simplePushConfig, final DataStore datastore, final SockJsConfig sockjsConfig, final EventExecutorGroup backgroundGroup) { this.simplePushConfig = simplePushConfig; this.datastore = datastore; this.sockjsConfig = sockjsConfig; this.backgroundGroup = backgroundGroup; privateKey = DefaultSimplePushServer.generateAndStorePrivateKey(datastore, simplePushConfig); if (sockjsConfig.isTls()) { sslContext = new WebSocketSslServerSslContext(sockjsConfig).sslContext(); } }
/** * Sole constructor. * * @param simplePushConfig the {@link SimplePushServerConfig} configuration. * @param datastore the {@link DataStore} to be passed to the {@link SimplePushServiceFactory}. * @param sockjsConfig the SockJS {@link SimplePushServerConfig}. * @param backgroundGroup an {@link EventExecutorGroup} to be used for the {@link UserAgentReaperHandler}. */ public SockJSChannelInitializer(final SimplePushServerConfig simplePushConfig, final DataStore datastore, final SockJsConfig sockjsConfig, final EventExecutorGroup backgroundGroup) { this.simplePushConfig = simplePushConfig; this.datastore = datastore; this.sockjsConfig = sockjsConfig; this.backgroundGroup = backgroundGroup; privateKey = DefaultSimplePushServer.generateAndStorePrivateKey(datastore, simplePushConfig); if (sockjsConfig.isTls()) { sslContext = new WebSocketSslServerSslContext(sockjsConfig).sslContext(); } }
final String wsUrl = getWebSocketLocation(config.isTls(), req); final WebSocketHAProxyHandshaker haHandshaker = new WebSocketHAProxyHandshaker(wsUrl, null, 65365); final ChannelFuture handshakeFuture = haHandshaker.handshake(ctx.channel(), req); return; final String wsUrl = getWebSocketLocation(config.isTls(), req, Transports.Type.WEBSOCKET.path()); final WebSocketServerHandshakerFactory wsFactory = new WebSocketServerHandshakerFactory(wsUrl, null, false); handshaker = wsFactory.newHandshaker(req);
final String wsUrl = getWebSocketLocation(config.isTls(), req); final WebSocketHAProxyHandshaker haHandshaker = new WebSocketHAProxyHandshaker(wsUrl, null, 65365); final ChannelFuture handshakeFuture = haHandshaker.handshake(ctx.channel(), req); return; final String wsUrl = getWebSocketLocation(config.isTls(), req, Transports.Type.WEBSOCKET.path()); final WebSocketServerHandshakerFactory wsFactory = new WebSocketServerHandshakerFactory(wsUrl, null, false); handshaker = wsFactory.newHandshaker(req);
final String wsUrl = getWebSocketLocation(config.isTls(), req, Transports.Type.WEBSOCKET.path()); final WebSocketServerHandshakerFactory wsFactory = new WebSocketServerHandshakerFactory(wsUrl, config.webSocketProtocolCSV(), false);
final String wsUrl = getWebSocketLocation(config.isTls(), req, Transports.Type.WEBSOCKET.path()); final WebSocketServerHandshakerFactory wsFactory = new WebSocketServerHandshakerFactory(wsUrl, config.webSocketProtocolCSV(), false);