Package org.springframework.web.socket.server.support

Examples of org.springframework.web.socket.server.support.HandshakeInterceptorChain


      logger.error("No handler configured for raw WebSocket messages");
      response.setStatusCode(HttpStatus.NOT_FOUND);
      return;
    }

    HandshakeInterceptorChain chain = new HandshakeInterceptorChain(this.interceptors, handler);
    HandshakeFailureException failure = null;

    try {
      Map<String, Object> attributes = new HashMap<String, Object>();
      if (!chain.applyBeforeHandshake(request, response, attributes)) {
        return;
      }
      ((HandshakeHandler) transportHandler).doHandshake(request, response, handler, attributes);
      chain.applyAfterHandshake(request, response, null);
    }
    catch (HandshakeFailureException ex) {
      failure = ex;
    }
    catch (Throwable ex) {
      failure = new HandshakeFailureException("Uncaught failure for request " + request.getURI(), ex);
    }
      finally {
      if (failure != null) {
        chain.applyAfterHandshake(request, response, failure);
        throw failure;
      }
    }
  }
View Full Code Here


        sendMethodNotAllowed(response, supportedMethod);
      }
      return;
    }

    HandshakeInterceptorChain chain = new HandshakeInterceptorChain(this.interceptors, handler);
    SockJsException failure = null;

    try {
      SockJsSession session = this.sessions.get(sessionId);
      if (session == null) {
        if (transportHandler instanceof SockJsSessionFactory) {
          Map<String, Object> attributes = new HashMap<String, Object>();
          if (!chain.applyBeforeHandshake(request, response, attributes)) {
            return;
          }
          SockJsSessionFactory sessionFactory = (SockJsSessionFactory) transportHandler;
          session = createSockJsSession(sessionId, sessionFactory, handler, attributes);
        }
        else {
          response.setStatusCode(HttpStatus.NOT_FOUND);
          if (logger.isDebugEnabled()) {
            logger.debug("Session not found, sessionId=" + sessionId +
                ". The session may have been closed " +
                "(e.g. missed heart-beat) while a message was coming in.");
          }
          return;
        }
      }

      if (transportType.sendsNoCacheInstruction()) {
        addNoCacheHeaders(response);
      }

      if (transportType.supportsCors()) {
        if (!checkAndAddCorsHeaders(request, response)) {
          return;
        }
      }

      transportHandler.handleRequest(request, response, handler, session);
      chain.applyAfterHandshake(request, response, null);
    }
    catch (SockJsException ex) {
      failure = ex;
    }
    catch (Throwable ex) {
      failure = new SockJsException("Uncaught failure for request " + request.getURI(), sessionId, ex);
    }
    finally {
      if (failure != null) {
        chain.applyAfterHandshake(request, response, failure);
        throw failure;
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.springframework.web.socket.server.support.HandshakeInterceptorChain

Copyright © 2018 www.massapicom. 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.