Package org.springframework.web.socket.sockjs

Examples of org.springframework.web.socket.sockjs.SockJsException


      SockJsFrame frame = SockJsFrame.closeFrameGoAway();
      try {
        response.getBody().write(frame.getContentBytes());
      }
      catch (IOException ex) {
        throw new SockJsException("Failed to send " + frame, sockJsSession.getId(), ex);
      }
    }
    else if (!sockJsSession.isActive()) {
      if (logger.isTraceEnabled()) {
        logger.trace("Starting " + getTransportType() + " async request.");
      }
      sockJsSession.handleSuccessiveRequest(request, response, getFrameFormat(request));
    }
    else {
      if (logger.isDebugEnabled()) {
        logger.debug("Another " + getTransportType() + " connection still open for " + sockJsSession);
      }
      String formattedFrame = getFrameFormat(request).format(SockJsFrame.closeFrameAnotherConnectionOpen());
      try {
        response.getBody().write(formattedFrame.getBytes(SockJsFrame.CHARSET));
      }
      catch (IOException ex) {
        throw new SockJsException("Failed to send " + formattedFrame, sockJsSession.getId(), ex);
      }
    }
  }
View Full Code Here


    try {
      return StringUtils.isEmpty(value) ? null : UriUtils.decode(value, "UTF-8");
    }
    catch (UnsupportedEncodingException e) {
      // should never happen
      throw new SockJsException("Unable to decode callback query parameter", null, e);
    }
  }
View Full Code Here

    try {
      response.setStatusCode(HttpStatus.INTERNAL_SERVER_ERROR);
      response.getBody().write(error.getBytes("UTF-8"));
    }
    catch (IOException ex) {
      throw new SockJsException("Failed to send error: " + error, sessionId, ex);
    }
  }
View Full Code Here

    super.handleRequestInternal(request, response, wsHandler, sockJsSession);
    try {
      response.getBody().write("ok".getBytes("UTF-8"));
    }
    catch (IOException ex) {
      throw new SockJsException("Failed to write to the response body", sockJsSession.getId(), ex);
    }
  }
View Full Code Here

        handleTransportRequest(request, response, wsHandler, sessionId, transport);
      }
      response.close();
    }
    catch (IOException ex) {
      throw new SockJsException("Failed to write to the response", null, ex);
    }
  }
View Full Code Here

      }
      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

      if (this.session.isDisconnected()) {
        if (logger.isDebugEnabled()) {
          logger.debug("SockJS sockJsSession closed, closing response.");
        }
        IoUtils.safeClose(this.connection);
        throw new SockJsException("Session closed.", this.session.getId(), null);
      }

      Pooled<ByteBuffer> pooled = this.connection.getBufferPool().allocate();

      try {
View Full Code Here

      if (!this.httpClient.isRunning()) {
        this.httpClient.start();
      }
    }
    catch (Exception e) {
      throw new SockJsException("Failed to start " + this, e);
    }
  }
View Full Code Here

      if (this.httpClient.isRunning()) {
        this.httpClient.stop();
      }
    }
    catch (Exception e) {
      throw new SockJsException("Failed to stop " + this, e);
    }
  }
View Full Code Here

      while (true) {
        if (this.sockJsSession.isDisconnected()) {
          if (logger.isDebugEnabled()) {
            logger.debug("SockJS sockJsSession closed, closing response.");
          }
          response.abort(new SockJsException("Session closed.", this.sockJsSession.getId(), null));
          return;
        }
        if (buffer.remaining() == 0) {
          break;
        }
View Full Code Here

TOP

Related Classes of org.springframework.web.socket.sockjs.SockJsException

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.