Ejemplo n.º 1
0
 @Override
 public void addMultiTypeEventListener(
     String eventName, MultiTypeEventListener listener, Class<?>... eventClass) {
   EventEntry entry = eventListeners.get(eventName);
   if (entry == null) {
     entry = new EventEntry();
     EventEntry<?> oldEntry = eventListeners.putIfAbsent(eventName, entry);
     if (oldEntry != null) {
       entry = oldEntry;
     }
   }
   entry.addListener(listener);
   jsonSupport.addEventMapping(name, eventName, eventClass);
 }
Ejemplo n.º 2
0
 @Override
 @SuppressWarnings({"unchecked", "rawtypes"})
 public <T> void addEventListener(
     String eventName, Class<T> eventClass, DataListener<T> listener) {
   EventEntry entry = eventListeners.get(eventName);
   if (entry == null) {
     entry = new EventEntry<T>();
     EventEntry<?> oldEntry = eventListeners.putIfAbsent(eventName, entry);
     if (oldEntry != null) {
       entry = oldEntry;
     }
   }
   entry.addListener(listener);
   jsonSupport.addEventMapping(name, eventName, eventClass);
 }
Ejemplo n.º 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);
  }