Monitor_Bot - import import import import import import...

Info iconThis 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{
Background image of page 1

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

View Full DocumentRight 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 !!"; query = "insert into em_smt_tran (mt_refkey, date_client_req, content, callback, service_type, broadcast_yn, msg_status, recipient_num)";
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/14/2011 for the course DD aa000 taught by Professor Bbb during the Spring '11 term at Korea University.

Page1 / 6

Monitor_Bot - import import import import import import...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online