Java Reference
In-Depth Information
Figure B.5 MazeRacergame: a) waiting for an opponent to join and b) multiplayer session
B.5.3 SNAP Mobile Client API
The SNAP Mobile Client API is a lightweight library for adding connected
features to Java games. It encapsulates all needed information and pro-
cedures from the server components into an easy-to-use Java API, so that
you can focus on building the game logic instead of network details,
matchmaking mechanisms, and so on.
Although easy to use, the API is extensive and in order to under-
stand it in full you need to study many concepts inherent to connected
games. In this appendix, we use the sample applications from SNAP
Mobile SDK to understand how to perform basic connected operations,
such as logging in and out, matchmaking, instant messaging, using
presence information, and getting rankings and player statistics. With
this baseline information in mind, you will able to dive deep into the
API documentation and build complex games utilizing the full power
of SNAP Mobile. For a full description of the API, study of example
games, and Frequently Asked Questions (FAQ), please check the SNAP
Mobile section of the Forum Nokia Java ME site:
com/main/market segments/games/snapmobile documents.html .
In this example, we see how to log in to SNAP Mobile and send,
receive, and echo messages from the game server. This is the code for the
HelloWorld MIDlet in a connected environment. Standard programming
tasks related to MIDP have been omitted from this code; the full source
code for all the examples can be found in the SampleApps folder of the
SNAP Mobile SDK.
import* ;
import* ;
// Basic SNAP Mobile login and messaging functionality.
public class HelloWorld extends MIDlet implements CommandListener {
Search WWH ::

Custom Search