Monitor_Bot - import import import import import import...

Info icon This preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
import java.net.*; import java.io.*; import java.util.*; import java.awt.*; import java.sql.*; import java.text.*; class URL_Monitor_Thread extends Thread{ private Monitor_Bot xMain_bot; public String check_name; public String check_url; private String select_query = ""; private String insert_query = ""; private String delete_query = ""; private String update_query = ""; private URL sendUrl = null; private URLConnection urlcon = null; private HttpURLConnection httpcon = null; public String[] arrSMSUser = null; public int failCount = 0; public int responseCode; public URL_Monitor_Thread(Monitor_Bot xbot, String sName, String sUrl){ super("session check bot"); xMain_bot = xbot; check_name = sName; check_url = sUrl; } public void Kill_Bot(){ this.stop(); xMain_bot = null; check_name = null; check_url = null; select_query = null; insert_query = null; delete_query = null; update_query = null; sendUrl = null; urlcon = null; httpcon = null; arrSMSUser = null; System.gc(); } public void run(){ try{ while(true){ if(check_session(this)){ failCount = 0; }else{ failCount ++; } if(failCount > 5){ send_alert_SMS(this); failCount = 0; xMain_bot.doFileWriter(this); } sleep(20000); } }catch(Exception w){ Kill_Bot(); } } public boolean check_session(URL_Monitor_Thread thd) throws IOException{
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
sendUrl = new URL(check_url); boolean rtnVal = false; try{ urlcon = sendUrl.openConnection(); httpcon = (HttpURLConnection)urlcon; responseCode = httpcon.getResponseCode(); if(responseCode == HttpURLConnection.HTTP_OK){ rtnVal = true; //System.out.println(responseCode); }else{ rtnVal = false; } }catch(IOException e){ rtnVal = false; } return rtnVal; } public void send_alert_SMS(URL_Monitor_Thread thd) throws IOException{ int SMSCnt = this.arrSMSUser.length; String strMsg = null, query = null; for(int i = 0; i < SMSCnt; i++){ strMsg = "[INFOBANK ]\n" + check_name + " URL ��� b !!"; �����
Image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern