コード例 #1
0
ファイル: HTTPServlet.java プロジェクト: KosBeg/jwebsocket
  private void processSync(String aConnectorId, HttpServletRequest aReq, HttpServletResponse aResp)
      throws IOException {
    try {
      String lOrigin = aReq.getScheme() + "://" + aReq.getRemoteHost();
      if (!EngineUtils.isOriginValid(lOrigin, mEngine.getConfiguration().getDomains())) {
        sendMessage(401, "Origin not allowed!", aResp);
        return;
      }

      List<String> lPackets = mConnectorsManager.getPacketsQueue().dequeue(aConnectorId);

      sendMessage(200, JSONProcessor.objectToJSONString(lPackets), aResp);
    } catch (Exception lEx) {
      sendMessage(500, lEx.getLocalizedMessage(), aResp);
    }
  }
コード例 #2
0
ファイル: HTTPServlet.java プロジェクト: KosBeg/jwebsocket
  private void processOpen(
      String aSessionId, String aConnectorId, HttpServletRequest aReq, HttpServletResponse aResp)
      throws IOException {
    try {
      String lOrigin = aReq.getScheme() + "://" + aReq.getRemoteHost();
      if (!EngineUtils.isOriginValid(lOrigin, mEngine.getConfiguration().getDomains())) {
        sendMessage(401, "Origin not allowed!", aResp);
        return;
      }

      mConnectorsManager.add(aSessionId, aConnectorId);
      HTTPConnector lConnector = getConnector(aConnectorId, aReq, aResp);
      lConnector.setRemoteHost(InetAddress.getByName(aReq.getRemoteHost()));

      // starting connector on request thread intentionally
      lConnector.startConnector();
    } catch (Exception lEx) {
      sendMessage(500, lEx.getLocalizedMessage(), aResp);
    }
  }