Class games.Battle.client.ClientApplet.ClientApplet
All Packages Class Hierarchy This Package Previous Next Index
Class games.Battle.client.ClientApplet.ClientApplet
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Container
|
+----java.awt.Panel
|
+----java.applet.Applet
|
+----games.Battle.client.ClientApplet.ClientApplet
- public class ClientApplet
- extends Applet
- implements Runnable
This is the main applet for the game portion of the client.
It organizes media resources and assembles a cohesively
executing client application to allow players to play
the game against others.
-
ClientApplet()
- Default constructor.
-
ClientApplet(PlayerInfo, EuropaClient, String, int)
- Data constructor.
-
connectToServer()
- Connect to the game server with the ip address and port
we have been constructed with.
-
destroy()
- Try to clean up everything that's going on in the game
client when the client is being shut down.
-
handleCommunicationException()
- Called if a problem communicating with the server is
encountered.
-
handleEvent(Event)
- Handle events occuring in the ClientApplet, most notably button
presses from the button bar.
-
init()
- Initialize the game client by setting up the button bar,
the client board and the board component which will process
the graphic display and parsing of user events.
-
main(String[])
-
-
play()
-
-
run()
- The game thread body.
-
setupGame()
- Set up the game by reading "preliminary" information
from the game server.
-
start()
- Executed when the ClientApplet actually "starts".
ClientApplet
public ClientApplet()
- Default constructor. The ip address is set to the loopback
ip and the port is set to 5000.
ClientApplet
public ClientApplet(PlayerInfo p,
EuropaClient applet,
String server,
int port)
- Data constructor. The server name and port are passed
here so a socket can be opened later. An instance of the
calling applet is also passed in here for administration.
- Parameters:
- applet - the parent applet
- server - the name of the machine running the server
- port - the port the game server is listening to
- See Also:
- PlayerInfo, EuropaClient
init
public void init()
- Initialize the game client by setting up the button bar,
the client board and the board component which will process
the graphic display and parsing of user events.
- Overrides:
- init in class Applet
start
public void start()
- Executed when the ClientApplet actually "starts". This method
actually oversees the creating of the communication to the
server and starts up the game.
- Overrides:
- start in class Applet
handleCommunicationException
public void handleCommunicationException()
- Called if a problem communicating with the server is
encountered. Throws up a dialog box allowing the user
to tell the game to keep trying to talk to the server
or to give up and kill the client.
connectToServer
public void connectToServer()
- Connect to the game server with the ip address and port
we have been constructed with.
setupGame
public void setupGame()
- Set up the game by reading "preliminary" information
from the game server. This includes receiving a GameInit
packet from the server (which contains game initialization
information), and also receiving a TerrainInit packet
from the server which gives a complete description of
the terrain to the client.
A ClientTimeoutAgent is invoked at the beginning of this
routine to monitor the time it takes to communicate
with the server. If there are troubles connecting with
the server, the agent will time out and give the user
the options of trying to continue communication or to
abort.
- See Also:
- GameInit, TerrainInit, ClientTimoutAgent
play
public void play()
run
public void run()
- The game thread body. This method fundamentally loops forever
(until it is either a) killed by the player or b) kills itself
via instructions from the server) and receives TurnDiffs from
the server and instructs its ClientUpdater to wake up and
redraw itself.
A ClientTimeoutAgent is reset at the beginning of each turn
iteration. If a single turn takes too long communicating
with the server the agent times out and allows the user
to continue trying to communicate with the server or abort
the game.
- See Also:
- ClientTimeoutAgent, TurnDiff, ClientUpdater
destroy
public void destroy()
- Try to clean up everything that's going on in the game
client when the client is being shut down.
- Overrides:
- destroy in class Applet
handleEvent
public boolean handleEvent(Event e)
- Handle events occuring in the ClientApplet, most notably button
presses from the button bar.
- Parameters:
- e - the event to process
- Overrides:
- handleEvent in class Component
main
public static void main(String argv[])
All Packages Class Hierarchy This Package Previous Next Index