コード例 #1
0
ファイル: AppSession.java プロジェクト: chujieyang/ice-demos
  //
  // Any exception destroys the session.
  //
  // Should only be called from the main thread.
  //
  private void destroyWithError(final String msg) {
    List<ChatRoomListener> copy;

    synchronized (this) {
      destroy();
      _error = msg;

      copy = new ArrayList<ChatRoomListener>(_listeners);
    }

    for (ChatRoomListener listener : copy) {
      listener.error();
    }
  }
コード例 #2
0
ファイル: AppSession.java プロジェクト: chujieyang/ice-demos
  // This method is only called by the UI thread.
  public synchronized String addChatRoomListener(ChatRoomListener cb, boolean replay) {
    _listeners.add(cb);
    cb.init(_users);

    if (replay) {
      // Replay the entire state.
      for (ChatEventReplay r : _replay) {
        r.replay(cb);
      }
    }

    if (_error != null) {
      cb.error();
    }

    return _hostname;
  }