コード例 #1
0
ファイル: DefaultClient.java プロジェクト: jingchan/jh_rogue
  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);
    }
  }
コード例 #2
0
ファイル: DefaultClient.java プロジェクト: jingchan/jh_rogue
 public void removeMessageListener(MessageListener<? super Client> listener) {
   messageListeners.removeMessageListener(listener);
 }
コード例 #3
0
ファイル: DefaultClient.java プロジェクト: jingchan/jh_rogue
 public void removeMessageListener(MessageListener<? super Client> listener, Class... classes) {
   messageListeners.removeMessageListener(listener, classes);
 }
コード例 #4
0
ファイル: DefaultClient.java プロジェクト: jingchan/jh_rogue
 public void addMessageListener(MessageListener<? super Client> listener) {
   messageListeners.addMessageListener(listener);
 }