You can communicate with this servlet at the address:
String servletAddress = "http://stage.itp.nyu.edu:8080/dano/servlet/PeersListServlet";
via http which is easily done in java:
//when you fist come on
URL myURL = new URL(servletAddress + "?action=add&address=" + myIPAndPort + "&app=" + app + "&timeout=" + timeout); //now you listen for what comes back, see the code
//remind the servlet that you are still interested in peers
URL myURL = new URL(servletAddress + "?action=refresh&address=" + myIPAndPort + "&app=" + app);
//take yourself off the list URL myURL = new URL(servletAddress + "?action=remove&address=" + myIPAndPort + "&app=" + app);
As you can see have to pass along a couple of parameters. Of course you have to send your ip and port so the others can find you. Send a timeout parameter so we can clean up after dead applicatons. The most important parameter is "app" Because this servlet is being used by everyone in the class, app allows you to filter out hearing about the peers of other people. In your code you should give yourself a unique app name:
String app = "changeThisMaybeNeID" + getClass().getName();
You debug things directly in a web browser by typing in these lines:
ObjectOutputStream objOut = new ObjectOutputStream(socket.getOutputStream()); objOut.write(myOb); //send it down the line
ObjectInputStream objIn = new ObjectInputStream(socket.getInputStream()); newObj = objIn.readObject(); //and voila it comes out the other side
public class OutsideClass {
bla
bla
bla going about my Outside class business
public class ListeningThread implements Runnable { //this just shows up like a method
public void run() {
.....Ya I get to use all the stuff from the outside class
}//end of the inner class ListeningThread
}//end of outside class
//This is a new way to make threads
listeningThread = new Thread(new ListeningThread());
listeningThread.start();