users@grizzly.java.net

Pojo client - a work in progress

From: Peter Murray <peter.murray_at_FXALL.com>
Date: Thu, 7 Feb 2008 08:54:12 -0500

I have attached a small client which talks to the "counter" example.
It works (renamed to counter2 for the moment) to the extent that it
increments the counter and get the "success" message back.

Is my next step to set up a
     CometHandler<HttpServletResponse>
class and have it listen for events from Comet as is done in the
servlet?

Thanks...


Peter


PS when I have this working as a client for counter I would like to
add it back to the example in SVN. Everyone in the world is not using
AJAX :)



public class CounterClient
{

     /**
      * @param args the command line arguments
      */
     public static void main(String[] args)
     {
         try
         {

             URL url = new URL("http://localhost:8080/counter2/long_polling
");
             URLConnection conn = url.openConnection();
             conn.setDoOutput(true);

             BufferedWriter out =
                     new BufferedWriter(new
OutputStreamWriter(conn.getOutputStream()));
             out.write("/counter2/long_polling\r\n");
             out.flush();
             out.close();
             BufferedReader in =
                     new BufferedReader(new
InputStreamReader(conn.getInputStream()));

             String response;
             while ((response = in.readLine()) != null)
             {
                 System.out.println(response);
                 Thread.sleep(1);
             }
         //in.close();
         }
         catch (MalformedURLException ex)
         {
             System.out.println("Exception: " + ex.toString());
         }
         catch (IOException ex)
         {
             System.out.println("Exception: " + ex.toString());
         }
         catch (InterruptedException ex)
         {
             System.out.println("Exception: " + ex.toString());
         }
     }
}


Peter Murray
Manager,
Relationship Trading

peter.murray_at_fxall.com
Office: +1 646-268-9916
Cell : +1 914-414-3727
AIM : retepmurray