private void shutdownSamp() { sampMonitorHandle.cancel(true); sampClient.setActive(false); sampClient = null; if (hub != null) { hub.shutdown(); } }
public synchronized void stopHub() { if (hub_ == null) { throw new IllegalStateException(); } hub_.shutdown(); hub_ = null; service_ = null; }
public synchronized void startHub() throws IOException { if (hub_ != null) { throw new IllegalStateException("Hub not stopped " + "due to earlier test failure?"); } service_ = new BasicHubService(createRandom()); hub_ = new Hub(service_); service_.start(); hub_.startProfile(createHubProfile()); }
private void monitorSampOnce() { logger.log(LEVEL, "Monitor State: "); logger.log(LEVEL, "sampClient.isConnected(): " + sampClient.isConnected()); logger.log(LEVEL, "sampClientProfile.isHubRunning(): " + sampClientProfile.isHubRunning()); try { logger.log(LEVEL, "sampClient.getConnection(): " + sampClient.getConnection()); } catch (IOException ex) { logger.log(Level.WARNING, "sampClient.getConnection(): exception", ex); } logger.log(LEVEL, "startingHub: " + startingHub); logger.log(LEVEL, "autoRunHub: " + autoRunHub); if (!sampClientProfile.isHubRunning() && !startingHub && autoRunHub) { logger.log(Level.INFO, "No Hub running, starting one ourselves"); startingHub = true; if (hub != null) { logger.log(Level.WARNING, "A hub was found, shutting it down before proceeding"); hub.shutdown(); } logger.log(Level.INFO, "Starting Hub"); try { hub = Hub.runHub(HubServiceMode.MESSAGE_GUI); } catch (IOException e) { logger.log( Level.WARNING, "A hub was found after all, trying to continue without starting our own"); } startingHub = false; } boolean newState; newState = sampClient.isConnected() && sampClientProfile.isHubRunning(); logger.log(LEVEL, "SAMP client connected: " + newState); if (newState != sampUp) { logger.log(Level.INFO, "Client connection status changed: " + sampUp + " -> " + newState); sampUp = newState; logger.log(LEVEL, "Calling connection listeners callbacks"); for (SAMPConnectionListener listener : sampListeners) { listener.run(sampUp); } } }