Exemple #1
0
 public void sendResponse(ClientEndpoint endpoint, Object response) {
   if (response instanceof Throwable) {
     response =
         ClientExceptionConverters.get(endpoint.getClientType()).convert((Throwable) response);
   }
   final Data resultData = response != null ? serializationService.toData(response) : NULL;
   Connection conn = endpoint.getConnection();
   conn.write(new DataAdapter(resultData, serializationService.getSerializationContext()));
 }
Exemple #2
0
 void bind(final ClientEndpoint endpoint) {
   final Connection conn = endpoint.getConnection();
   if (conn instanceof TcpIpConnection) {
     Address address = new Address(conn.getRemoteSocketAddress());
     TcpIpConnectionManager connectionManager =
         (TcpIpConnectionManager) node.getConnectionManager();
     connectionManager.bind((TcpIpConnection) conn, address, null, false);
   }
   sendClientEvent(endpoint);
 }
Exemple #3
0
 public void shutdown() {
   for (ClientEndpoint endpoint : endpoints.values()) {
     try {
       endpoint.destroy();
     } catch (LoginException e) {
       logger.finest(e.getMessage());
     }
     try {
       final Connection conn = endpoint.getConnection();
       if (conn.live()) {
         conn.close();
       }
     } catch (Exception e) {
       logger.finest(e);
     }
   }
   endpoints.clear();
 }
Exemple #4
0
  private void destroyEndpoint(ClientEndpoint endpoint, boolean closeImmediately) {
    if (endpoint != null) {
      logger.info("Destroying " + endpoint);
      try {
        endpoint.destroy();
      } catch (LoginException e) {
        logger.warning(e);
      }

      final Connection connection = endpoint.getConnection();
      if (closeImmediately) {
        try {
          connection.close();
        } catch (Throwable e) {
          logger.warning("While closing client connection: " + connection, e);
        }
      } else {
        nodeEngine
            .getExecutionService()
            .schedule(
                new Runnable() {
                  public void run() {
                    if (connection.live()) {
                      try {
                        connection.close();
                      } catch (Throwable e) {
                        logger.warning("While closing client connection: " + e.toString());
                      }
                    }
                  }
                },
                1111,
                TimeUnit.MILLISECONDS);
      }
      sendClientEvent(endpoint);
    }
  }