Beispiel #1
0
  protected void dispatch(Message m) {
    // Pull off the connection management messages we're
    // interested in and then pass on the rest.
    if (m instanceof ClientRegistrationMessage) {
      // Then we've gotten our real id
      this.id = (int) ((ClientRegistrationMessage) m).getId();
      log.log(Level.INFO, "Connection established, id:{0}.", this.id);
      connecting.countDown();
      fireConnected();
      return;
    }
    if (m instanceof DisconnectMessage) {
      // Can't do too much else yet
      String reason = ((DisconnectMessage) m).getReason();
      log.log(Level.SEVERE, "Connection terminated, reason:{0}.", reason);
      DisconnectInfo info = new DisconnectInfo();
      info.reason = reason;
      fireDisconnected(info);
      close();
    }

    // Make sure client MessageListeners are called single-threaded
    // since it could receive messages from the TCP and UDP
    // thread simultaneously.
    synchronized (this) {
      messageListeners.messageReceived(this, m);
    }
  }
Beispiel #2
0
 public void removeMessageListener(MessageListener<? super Client> listener) {
   messageListeners.removeMessageListener(listener);
 }
Beispiel #3
0
 public void removeMessageListener(MessageListener<? super Client> listener, Class... classes) {
   messageListeners.removeMessageListener(listener, classes);
 }
Beispiel #4
0
 public void addMessageListener(MessageListener<? super Client> listener) {
   messageListeners.addMessageListener(listener);
 }