/** * 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(); }
/** * Watches an event. * * @throws IOException I/O exception */ private void watch() throws IOException { server.initEvents(); // initialize server-based event handling if (!events) { out.writeString(Integer.toString(context.mprop.num(MainProp.EVENTPORT))); out.writeString(Long.toString(getId())); out.flush(); events = true; } 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.add(this); message = WATCHING_EVENT_X; } else if (s == null) { message = EVENT_UNKNOWN_X; } else { message = EVENT_WATCHED_X; } info(Util.info(message, name), ok); }