Menu

Usage

Usage (1)
Mats Andreassen

jOpenTTDLib usage

The entry point for the library is the GameQuerier interface. There is currently only one implementation: UDPGameQuerier. This object can be used thusly:

GameQuerier q = new UDPGameQuerier( host, localPort, port );
Game game = q.getAllInformation();
System.out.println( game.toString() );

This prints all the information the GameQuerier has gathered.

If you want to monitor a server and listen for events:

OpenTTDListener myListener = null; // Implement your listener
ServerMonitor mon = new ServerMonitor( gameQuerier, 2000, false);
mon.addListeners( myListener );
mon.start();

Calling start will cause it to spawn a poller thread and start monitoring the specified server by polling it every 2 seconds. If you've added at least one listener, events will fire which your listeners can handle.

Maven artifact

Coming soon, hopefully!


Related

Wiki: Changelog-2.0.0
Wiki: Home

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.