Difference between revisions of "Java"

From Open Rail Data Wiki
Jump to navigation Jump to search
Line 1: Line 1:
 +
==Gorizza Stomp library==
 +
 +
This code requires the [http://www.germane-software.com/software/Java/Gozirra/ Gozirra Stomp library].
 +
 
<code>
 
<code>
 
  private static void go() throws Exception
 
  private static void go() throws Exception
Line 24: Line 28:
 
     }
 
     }
 
</code>
 
</code>
Requires [http://www.germane-software.com/software/Java/Gozirra/ Gozirra Stomp library]
 

Revision as of 20:51, 31 July 2012

Gorizza Stomp library

This code requires the Gozirra Stomp library.

private static void go() throws Exception
   {
       System.out.println("Connecting");
       final Client c = new Client(Constants.SERVER, Constants.PORT, Constants.USERNAME, Constants.PASSWORD);
       System.out.println("Connected");
       System.out.println("Subscribing");
       for (final String topic : Constants.TOPICS)
       {
           System.out.println("  " + topic);
           c.subscribe("/topic/" + topic,
                   new Listener()
                   {
                       public void message(Map map, String s)
                       {
                           processMessage(map, s);
                       }
                   });
       }
       System.out.println("done subscribing");
   }