예제 #1
0
  /**
   * Unwatches an event.
   *
   * @throws IOException I/O exception
   */
  private void unwatch() throws IOException {
    final String name = in.readString();

    final Sessions s = context.events.get(name);
    final boolean ok = s != null && s.contains(this);
    final String message;
    if (ok) {
      s.remove(this);
      message = UNWATCHING_EVENT_X;
    } else if (s == null) {
      message = EVENT_UNKNOWN_X;
    } else {
      message = EVENT_NOT_WATCHED_X;
    }
    info(Util.info(message, name), ok);
    out.flush();
  }
예제 #2
0
  /** Exits the session. */
  public synchronized void quit() {
    running = false;
    if (log != null) log.write(this, "LOGOUT " + context.user.name, OK);

    // wait until running command was stopped
    if (command != null) {
      command.stop();
      while (command != null) Performance.sleep(50);
    }
    context.delete(this);

    try {
      new Close().execute(context);
      socket.close();
      if (events) {
        esocket.close();
        // remove this session from all events in pool
        for (final Sessions s : context.events.values()) s.remove(this);
      }
    } catch (final Exception ex) {
      if (log != null) log.write(ex.getMessage());
      Util.stack(ex);
    }
  }