Global Positioning System Reference
In-Depth Information
TheJavaTutorial>PuttingItAllTogether
>CommunicationbetweentheGameandthePlayer
... the Game and the Players have two different forms of
communication and use two different mechanisms for them.
First, the Game broadcasts status information to all the Play-
ers over UDP. Second, the Player makes individual requests of
the Game via RMI.
RMI communication can be compared to a phone call between two di-
rectly connected individual devices, while broadcasting via a multicast
socket is similar to a radio station transmitting information to anyone lis-
tening. In the context of a ROApp, the server could choose not to commu-
nicate through the RMI connection, but simply inform a \public audience"
about the ongoings. Broadcasting relieves the server, since it doesn't have
to wait for a method to return. And it can also relieve the client as it can
choose to use the information, simply ignore it, or not even listen to it in
the first place.
Again, the architect has to make a decision to add another communica-
tion technique or keep the focus on the overall progress. In order to make a
qualified decision, the analysis process should be pointed out regardless of
the choice. This section represents a protocol of the analysis phase, thor-
ough enough to pick it up in a later stage or cycle. For a global real-object
framework composed of ROServers and ROApps, it makes a lot of sense to
broadcast general information and give the clients a chance to see what's
going on before they choose to participate in a scenario. Servers may also
want to listen to the ROServer layer and choose to collaborate with it, i.e.,
use its server objects as a trusted source.
How It Works
Broadcasting is accomplished using User Datagram Protocol (UDP) and
does not require point-to-point connections. Rather, it sends packages,
packets, or datagrams and does not have control over their arrival. The
methods java.net.DatagramPacket and DatagramSocket implement UDP.
The DatagramPacket can be simplified to a byte array containing any in-
formation the sender (packing the packet) chooses to send. The receiver
of the packet has to know how to unpack the information and what to do
with it. Like (re)constructing a java Object .
The class bingo.shared.PlayerRecord has three steps:
public class PlayerRecord {
// content of the class:
 
Search WWH ::




Custom Search