Examples of WebSocketFactory


Examples of er.woadaptor.websockets.WebSocketFactory

      }
    }
   
    protected void handleUpgradeRequest(ChannelHandlerContext ctx, HttpRequest req) {
      //If factory doesn't exist, close the upgrade request channel
      WebSocketFactory factory = WebSocketStore.defaultWebSocketStore().factory();
      if(factory == null) {
        ctx.getChannel().close();
        return;
      }
     
      WebSocketServerHandshakerFactory wsFactory = new WebSocketServerHandshakerFactory(
                  ERWOAdaptorUtilities.getWebSocketLocation(req), null, false);
      handshaker = wsFactory.newHandshaker(req);
     
      Channel socketChannel = ctx.getChannel();
      if(handshaker == null) {
        wsFactory.sendUnsupportedWebSocketVersionResponse(socketChannel);
      } else {
        ChannelFuture future = handshaker.handshake(socketChannel, req);
        //TODO tie this to the channel future result?
        //Create a WebSocket instance to handle frames
        WebSocket socket = factory.create(socketChannel, req);
        WebSocketStore.defaultWebSocketStore().takeSocketForChannel(socket, socketChannel);
       
        socket.didUpgrade();
      }
    }
View Full Code Here

Examples of org.eclipse.jetty.websocket.WebSocketFactory

    public JettyAsyncSupport(AtmosphereConfig config) {
        super(config);
        final WebSocketProcessor webSocketProcessor = WebSocketProcessorFactory.getDefault().getWebSocketProcessor(config.framework());

        WebSocketFactory wsf;
        try {
            String[] jettyVersion = config.getServletContext().getServerInfo().substring(6).split("\\.");
            if (Integer.valueOf(jettyVersion[0]) > 7 || Integer.valueOf(jettyVersion[0]) == 7 && Integer.valueOf(jettyVersion[1]) > 4) {
                wsf = JettyWebSocketUtil.getFactory(config, webSocketProcessor);
            } else {
View Full Code Here

Examples of org.eclipse.jetty.websocket.WebSocketFactory

        String s = config.getInitParameter(ApplicationConfig.BUILT_IN_SESSION);
        if (s != null) {
            useBuildInSession.set(Boolean.valueOf(s));
        }

        WebSocketFactory webSocketFactory = new WebSocketFactory(new WebSocketFactory.Acceptor() {
            public boolean checkOrigin(HttpServletRequest request, String origin) {
                // Allow all origins
                logger.trace("WebSocket-checkOrigin request {} with origin {}", request.getRequestURI(), origin);
                return true;
            }

            public org.eclipse.jetty.websocket.WebSocket doWebSocketConnect(HttpServletRequest request, String protocol) {
                logger.trace("WebSocket-connect request {} with protocol {}", request.getRequestURI(), protocol);

                boolean isDestroyable = false;
                String s = config.getInitParameter(ApplicationConfig.RECYCLE_ATMOSPHERE_REQUEST_RESPONSE);
                if (s != null && Boolean.valueOf(s)) {
                    isDestroyable = true;
                }

                if (!webSocketProcessor.handshake(request)) {
                    // res.sendError(HttpServletResponse.SC_FORBIDDEN, "WebSocket requests rejected.");
                    throw new IllegalStateException();
                }

                return new JettyWebSocketHandler(AtmosphereRequest.cloneRequest(request, false, useBuildInSession.get(), isDestroyable),
                        config.framework(), webSocketProcessor);
            }
        });

        int bufferSize = 8192;
        if (config.getInitParameter(ApplicationConfig.WEBSOCKET_BUFFER_SIZE) != null) {
            bufferSize = Integer.valueOf(config.getInitParameter(ApplicationConfig.WEBSOCKET_BUFFER_SIZE));
        }
        logger.debug("WebSocket Buffer size {}", bufferSize);
        webSocketFactory.setBufferSize(bufferSize);

        int timeOut = 5 * 60000;
        if (config.getInitParameter(ApplicationConfig.WEBSOCKET_IDLETIME) != null) {
            timeOut = Integer.valueOf(config.getInitParameter(ApplicationConfig.WEBSOCKET_IDLETIME));
        }
        logger.debug("WebSocket idle timeout {}", timeOut);
        webSocketFactory.setMaxIdleTime(timeOut);

        int maxTextBufferSize = 8192;
        if (config.getInitParameter(ApplicationConfig.WEBSOCKET_MAXTEXTSIZE) != null) {
            maxTextBufferSize = Integer.valueOf(config.getInitParameter(ApplicationConfig.WEBSOCKET_MAXTEXTSIZE));
        }
        logger.debug("WebSocket maxTextBufferSize {}", maxTextBufferSize);
        webSocketFactory.setMaxTextMessageSize(maxTextBufferSize);

        int maxBinaryBufferSize = 8192;
        if (config.getInitParameter(ApplicationConfig.WEBSOCKET_MAXBINARYSIZE) != null) {
            maxBinaryBufferSize = Integer.valueOf(config.getInitParameter(ApplicationConfig.WEBSOCKET_MAXBINARYSIZE));
        }
        logger.debug("WebSocket maxBinaryBufferSize {}", maxBinaryBufferSize);
        webSocketFactory.setMaxBinaryMessageSize(maxBinaryBufferSize);

        if (config.getInitParameter(ApplicationConfig.JETTY_WEBSOCKET_MIN_VERSION) != null) {
            int minVersion = Integer.valueOf(config.getInitParameter(ApplicationConfig.JETTY_WEBSOCKET_MIN_VERSION));
            webSocketFactory.setMinVersion(minVersion);
            logger.debug("WebSocket Jetty minVersion {}", minVersion);
        }

        return webSocketFactory;
    }
View Full Code Here

Examples of org.eclipse.jetty.websocket.WebSocketFactory

    public JettyAsyncSupportWithWebSocket(final AtmosphereConfig config) {
        super(config);
        final WebSocketProcessor webSocketProcessor = WebSocketProcessorFactory.getDefault().getWebSocketProcessor(config.framework());

        WebSocketFactory wsf;
        try {
            String[] jettyVersion = config.getServletContext().getServerInfo().substring(6).split("\\.");
            if (Integer.valueOf(jettyVersion[0]) > 7 || Integer.valueOf(jettyVersion[0]) == 7 && Integer.valueOf(jettyVersion[1]) > 4) {
                wsf = JettyWebSocketUtil.getFactory(config, webSocketProcessor);
            } else {
View Full Code Here

Examples of org.eclipse.jetty.websocket.WebSocketFactory

    super.init(isServlet, filterConfig);

    try
    {
      String bs = filterConfig.getInitParameter("bufferSize");
      _webSocketFactory = new WebSocketFactory(this, bs == null ? 8192 : Integer.parseInt(bs));
      _webSocketFactory.start();

      String max = filterConfig.getInitParameter("maxIdleTime");
      if (max != null)
        _webSocketFactory.setMaxIdleTime(Integer.parseInt(max));
View Full Code Here

Examples of org.eclipse.jetty.websocket.WebSocketFactory

    super.init(isServlet, filterConfig);

    try
    {
      String bs = filterConfig.getInitParameter("bufferSize");
      _webSocketFactory = new WebSocketFactory(this, bs == null ? 8192 : Integer.parseInt(bs));
      _webSocketFactory.start();

      String max = filterConfig.getInitParameter("maxIdleTime");
      if (max != null)
        _webSocketFactory.setMaxIdleTime(Integer.parseInt(max));
View Full Code Here

Examples of org.eclipse.jetty.websocket.WebSocketFactory

    public void init(AbstractHTTPDestination dest) {
        this.destination = dest;

        //TODO customize websocket factory configuration options when using the destination.
        webSocketFactory = new WebSocketFactory((Acceptor)dest, 8192);
    }
View Full Code Here

Examples of org.eclipse.jetty.websocket.WebSocketFactory

    public void init(AbstractHTTPDestination dest) {
        this.destination = dest;

        //TODO customize websocket factory configuration options when using the destination.
        webSocketFactory = new WebSocketFactory((Acceptor)dest, 8192);

        // the executor for decoupling the service invocation from websocket's onMessage call which is
        // synchronously blocked
        executor = dest.getBus().getExtension(WorkQueueManager.class).getAutomaticWorkQueue();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.