Yahoo status monitor


bismillah..

Ok.. the case is, there is someone.. um.. ok.. some people I want to monitor when they got online. Not as invisible, just the regular online. So, here are the code :

MonitorThread.java

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

//package yahoostatusmonitor;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import javax.swing.JOptionPane;

/**
 *
 * @author Z10MQ.ATQ3B1T
 */
public class MonitorThread extends Thread{
    String names[] = null;
    String listOfOnlines = null;
    boolean isRunning = true;

    public MonitorThread(String nameList[]){

        this.names = nameList;
    }

    public void run(){

        while (isRunning) {

            //list of online users
            listOfOnlines = "";

            for (String i:names){

                System.out.println("monitoring : "+i);
                try{

                    // Create a URL for the desired page
                    URL url = new URL("http://mail.opi.yahoo.com/online?u="+i+"&m=a&t=1");

                    // Read all the text returned by the server
                    BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream()));
                    String str;
                    str = in.readLine();

                    if (str.equals("01")){
                        listOfOnlines += "    + " + i + "n";
                    }

                    in.close();

                }catch (IOException ioe) {
                    ioe.printStackTrace();
                }
            }

            if(!listOfOnlines.equals("")){
                //show the message status
                JOptionPane.showMessageDialog(null, "These people are online:n"+listOfOnlines);
            }

            try{
                Thread.sleep(180000);
            }catch (InterruptedException ie) {
                ie.printStackTrace();
            }

        }

    }

    public void setRunning( boolean isRunning){
        this.isRunning = isRunning;
    }

}

And here is the Manager thread, just the base for another advance features :

MonitorManager.java

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

//package yahoostatusmonitor;

/**
 *
 * @author Z10MQ.ATQ3B1T
 */
public class MonitorManager {

    public static void main(String args[]){

        Thread m1 = new MonitorThread(args);

        m1.start();
    }

}

And to run the java class is by :

java MonitorManager <list of  users>

~cheers

~nvmd

,

  1. #1 by nilam on March 10, 2009 - 3:26 pm

    trus biar apa dimonitor?

  2. #2 by life choice on March 10, 2009 - 4:45 pm

    OMG! udah lama banget ga liat ginian…
    coding coding coding..
    huaaaaaaaa..

    _nyiell_

    • #3 by havban on March 11, 2009 - 12:32 am

      @nilam:
      Biar ketauan kalo dia online.. just wanna chat ama dia aja..🙂

    • #4 by havban on March 11, 2009 - 12:33 am

      @nyiell:
      Iya.. refreshing jg bu.. kebanyakan liat console.. jadinya gelap niy mata.. kkk.
      Pengen liat yg putih2 sekali2.. *layar Netbeans maksudnya.. :P*

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: