Ejemplo 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();
  }
Ejemplo n.º 2
0
 public <T> void removeHandler(EventHandler<T> eh) {
   dispatcher.removeHandler(eh);
 }
Ejemplo n.º 3
0
 public <T> void addHandler(EventHandler<T> eh) {
   dispatcher.addHandler(eh);
 }