Esempio n. 1
0
  private void stopGame() {

    HashMap<EventHandler<?>, WorkerThread<?>> hMap = dispatcher.getMap();
    Iterator<?> it = hMap.keySet().iterator();

    WorkerThread<?> thread = null;
    Handle<?> handle = null;
    EventHandler<?> eh = null;

    while (it.hasNext()) {
      eh = (EventHandler<?>) it.next();
      handle = eh.getHandle();
      thread = hMap.get(eh);

      /* If it is the server-socket, then close it */
      if (handle instanceof AcceptHandle) {
        ((AcceptHandle) handle).close();
      }
      /* If it is the client-socket, then close it */
      else {
        ((TCPHandle) handle).close();
      }

      if (thread != null) {
        thread.cancelThread();
      }
    }
    hMap.clear();
  }
Esempio n. 2
0
 public <T> void removeHandler(EventHandler<T> eh) {
   dispatcher.removeHandler(eh);
 }
Esempio n. 3
0
 public <T> void addHandler(EventHandler<T> eh) {
   dispatcher.addHandler(eh);
 }