Newsletter

Mobile Handset DesignLine  >  Design Center

Mobile Game Networking Essentials--Part IV

Here is Part IV of Chapter 14 from Beginning Mobile Phone Game Programming. Wireless network games bring with them their own unique set of problems and challenges that must be dealt with at the design level. Included in the excerpt are many techniques for solving them. For those of you who design mobile games, it's packed with great information--for the rest of you--it's an informative and fun read.

Page 1 of 4

Mobile Handset DesignLine

See Part I,Part II, Part III

Building the Lighthouse Example
Many years before mobile phones and radio transmitters and receivers, a more primitive form of communication was used by seafarers. I'm talking about lighthouses, which are typically perched on the highest point of a shore, and include a light near the top that helps provide guidance and communication to ships at sea. Although today's lighthouses use modern communications technology such as radios, they still rely on a light for simple visual communication. Because mobile phones are themselves a modern form of personal communication, I thought a lighthouse theme might serve as a good example for a network MIDlet.

One way that lighthouses have been used for communications is through Morse code, which is a simple but highly effective method of communicating words and characters with sequences of "dots" and "dashes." A dot is a short visual or audible signal such as the flash of a light or a metallic click. A dash is defined as approximately three times the length of a dot, which equates to a light flash of longer duration or a longer resonating sound. You assemble sequences of dots and dashes to spell out words and sentences. Following are the alphanumeric codes that make up the International Morse Code standard:


Using these codes, you can assemble words and sentences; each letter has a brief pause between it and the next letter, whereas each sentence has a longer pause. Following is an example of the word "hello" coded in Morse:



Getting back to the Lighthouse example MIDlet, the idea is to simulate a lighthouse on a mobile phone, and use Morse code to communicate with another mobile phone by flashing the lighthouse light. It works like this: Each phone displays an image of a lighthouse. You are looking at the other person's lighthouse, while that person is looking at your lighthouse. You use the left and right directional keys to signal dots and dashes over a wireless network connection, after which the lighthouse seen by the other person resolves the dots and dashes into light flashes.

Construction Cue: An even simpler version of the Lighthouse MIDlet could rely on a single key to send both dots and dashes, in which case it would be up to the user to time them appropriately. This would more closely mimic a true telegraph, although it would make the example a bit less interesting.

The Lighthouse MIDlet is basically a high-tech simulation of a low-tech form of communication. From a mobile game programming perspective, it is very important in that it demonstrates how to establish a client-server connection between peer devices, and then send messages back and forth between them.

Designing the Client and Server
The Lighthouse MIDlet takes advantage of a client-server relationship between two mobile phones. The actual connection between the MIDlets is a datagram connection, which means that the messages sent between the phones are packaged as datagram packets. The client-server aspect of the Lighthouse design primarily has to do with which phone initiates the network connection. The following steps outline what takes place between client and server phones in the Lighthouse MIDlet:

  1. The server phone opens a datagram connection and waits for the client.
  2. The client phone opens a datagram connection with the server.
  3. With a connection established, the client and server phones send and receive messages.
  4. The client and server phones terminate the connection.



Page 2: next page  

Page 1 | 2 | 3 | 4



Rate this article
WORSE | BETTER
1 2 3 4 5




 Featured Jobs
ON Semiconductor seeking Design Manager in Phoenix, AZ

True Circuits seeking Mixed-Signal IC Layout Engnr in Los Altos, CA

Protingent Staffing seeking Analog ASIC Engineer in Bothell, WA

Lowe's seeking Systems Engineer III in Mooresville, NC

Center for Nanoscale Sci and Tech seeking Operations Mangr in Gaithersburg, MD

More jobs on EETimesCareers
 Sponsor
 CAREER CENTER
Ready to take that job and shove it?
SEARCH JOBS:

 SPONSOR

 RECENT JOB POSTINGS
For more great jobs, career related news, features and services, please visit EETimes' Career Center.