Exemple #1
0
 private void monitorSherpaOnce() {
   boolean newState;
   try {
     newState = pingSherpa();
     logger.log(LEVEL, "Sherpa client connected: " + newState);
     if (sherpaUp.compareAndSet(!newState, newState)) {
       logger.log(
           Level.INFO,
           "Sherpa Client connection status changed: " + !newState + " -> " + newState);
       for (SAMPConnectionListener listener : sherpaListeners) {
         listener.run(newState);
       }
     }
   } catch (Exception e) {
     logger.log(Level.WARNING, "SampException while pinging Sherpa", e);
   }
 }
Exemple #2
0
 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);
     }
   }
 }
Exemple #3
0
 public void addSherpaConnectionListener(SAMPConnectionListener listener) {
   sherpaListeners.add(listener);
   listener.run(sherpaUp.get());
 }
Exemple #4
0
 public void addSampConnectionListener(SAMPConnectionListener listener) {
   sampListeners.add(listener);
   listener.run(sampUp);
 }