public void activate(HomeService service) { super.activate(service); isRunning = true; listenThread = new Thread(this, "TCPListenThread"); listenThread.start(); eventThread = new Thread("CommandPortEventDistributor") { @Override public void run() { eventDistributorTask(); } }; eventThread.start(); }
public void stop() { isRunning = false; // Close listening socket try { if (serverSocket != null) { serverSocket.close(); } } catch (IOException e) { logger.warning(e.toString()); } // Stop the event distribution thread by sending the quit event Event quitEvent = server.createEvent(QUIT_EVENT, ""); receiveEvent(quitEvent); // Stop all open sessions LinkedList<Session> temp = new LinkedList<Session>(sessions); for (Session s : temp) { s.stop(); } super.stop(); }