Example #1
0
  public void onConnect(SocketIOClient client) {
    join(getName(), client.getSessionId());
    storeFactory
        .pubSubStore()
        .publish(
            PubSubStore.JOIN, new JoinLeaveMessage(client.getSessionId(), getName(), getName()));

    try {
      for (ConnectListener listener : connectListeners) {
        listener.onConnect(client);
      }
    } catch (Exception e) {
      exceptionListener.onConnectException(e, client);
    }
  }
Example #2
0
  public void onDisconnect(SocketIOClient client) {
    allClients.remove(client.getSessionId());

    leave(getName(), client.getSessionId());
    storeFactory
        .pubSubStore()
        .publish(
            PubSubStore.LEAVE, new JoinLeaveMessage(client.getSessionId(), getName(), getName()));

    try {
      for (DisconnectListener listener : disconnectListeners) {
        listener.onDisconnect(client);
      }
    } catch (Exception e) {
      exceptionListener.onDisconnectException(e, client);
    }
  }
Example #3
0
  @SuppressWarnings({"rawtypes", "unchecked"})
  public void onEvent(
      NamespaceClient client, String eventName, List<Object> args, AckRequest ackRequest) {
    EventEntry entry = eventListeners.get(eventName);
    if (entry == null) {
      return;
    }

    try {
      Queue<DataListener> listeners = entry.getListeners();
      for (DataListener dataListener : listeners) {
        Object data = getEventData(args, dataListener);
        dataListener.onData(client, data, ackRequest);
      }
    } catch (Exception e) {
      exceptionListener.onEventException(e, args, client);
      if (ackMode == AckMode.AUTO_SUCCESS_ONLY) {
        return;
      }
    }

    sendAck(ackRequest);
  }
 @Override
 public void exceptionCaught(ChannelHandlerContext ctx, Throwable e) throws Exception {
   if (!exceptionListener.exceptionCaught(ctx, e)) {
     super.exceptionCaught(ctx, e);
   }
 }