Using Hogs tools in your own applications

The Hogs codebase is available in two packages (each distributed in a jar file). The first and most obvious of these is hogsfull.jar, which contains all code necessary to run Hogs. This includes:

  1. Graphics, physics, and networking engines
  2. Controller, which combines all subparts into a single, playable game.
  3. Tools like the player customizer and the games browser.

The last of these (the Hogs tools) can be downloaded in a separate package, called hogsconn.jar. It includes classes useful for browsing and pinging remote servers. Their use should be fairly evident from the Javadocs, but here's an example:

import hogs.tools.*;
public class ExternalHogsBrowser {
    public static void main(String[] args) {
		// look for servers 3h, 2d, and 4c (these are hostnames).
        Browse br = new Browse(new String[]{"3h", "2d", "4c"});
        br.queryAll();
		
		// either insert some code here to wait for the pinging to
		// finish, or use a handler (see Browse javadocs).
        for(Browse.Host h : br.getHosts()) {
            System.out.println(h.hostname);
        }
    }
}

To use this code, make sure the hogsconn.jar is on your classpath at compile-time as well as run-time.



Hogs Project 2005-05-15