All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.minlia.cross.thread.PingThread Maven / Gradle / Ivy

There is a newer version: 1.0.9.RELEASE
Show newest version
package com.minlia.cross.thread;

import com.minlia.cross.client.NgrokClient;
import com.minlia.cross.message.MessageSender;
import java.io.IOException;
import java.net.SocketException;
import javax.net.ssl.SSLSocket;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class PingThread extends Thread {

  SSLSocket sock;
  NgrokClient ngrokcli;

  public PingThread(NgrokClient ngrokcli, SSLSocket s) {
    super();
    this.ngrokcli = ngrokcli;
    this.sock = s;
  }

  public void run() {
    while (ngrokcli.trfalg) {
      try {
        try {
          MessageSender.SendPing(sock.getOutputStream());
        } catch (SocketException e) {
          ngrokcli.trfalg = false;
        }
        log.debug("Ping ....");
      } catch (IOException e) {
        ngrokcli.trfalg = false;
      }
      try {
        Thread.sleep(30000);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
    }

  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy