|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectedu.uiuc.cs397rhc.game.GameDaemon
Listens to the net server for game events and fires them to registered listeners. The net server sends a stream of TCP packets that represent various game events and the game state.
| Field Summary | |
|---|---|
static java.lang.String |
DEFAULT_HOST
A random default server. |
static int |
DEFAULT_PORT
The default port that the net server runs on. |
| Constructor Summary | |
|---|---|
GameDaemon()
Constructs a game daemon listening to the default host and port. |
|
GameDaemon(java.lang.String host)
|
|
GameDaemon(java.lang.String host,
int port)
Constructs a game daemon listening to the specified port on the specified host. |
|
| Method Summary | |
|---|---|
void |
addGameListener(GameListener l)
Registers a GameListener to receive events from this source. |
void |
fireGameEvent(GameEvent ge)
Fires a game event off to every registered listener. |
static float |
leFloatToBEFloat(int lefloat)
Converts a 4-byte ( int) little-endian representation of a
float into a usable big-endian float. |
static long |
leUIntToBELong(int leuint)
Converts a 4-byte ( int) little-endian representation of an
unsigned integer into a usable big-endian long. |
static int |
leUIntToBEUInt(int leuint)
Converts a 4-byte ( int) little-endian representation of an
unsigned integer into a make-believe Java uint. |
void |
removeGameListener(GameListener l)
Removes a registered listener from the list receiving events. |
void |
run()
Runs the main listening and event firing loop. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int DEFAULT_PORT
public static final java.lang.String DEFAULT_HOST
| Constructor Detail |
|---|
public GameDaemon()
public GameDaemon(java.lang.String host)
public GameDaemon(java.lang.String host,
int port)
| Method Detail |
|---|
public void run()
GameEvents and fired off
to registered listeners.
run in interface java.lang.Runnablepublic static float leFloatToBEFloat(int lefloat)
int) little-endian representation of a
float into a usable big-endian float. Designed to be
used with readInt() and the like, which may be operating on
little-endian streams.
lefloat - the int representation of the little-endian
float
floatpublic static long leUIntToBELong(int leuint)
int) little-endian representation of an
unsigned integer into a usable big-endian long. Designed to be
used with readInt() and the like, which may be operating on
little-endian streams.
leuint - the int representation of the little-endian
unsigned integer
longpublic static int leUIntToBEUInt(int leuint)
int) little-endian representation of an
unsigned integer into a make-believe Java uint. All this
actually does is reverse the bytes in the specified integer.
Designed to be used with readInt() and the like, which may
be operating on little-endian streams.
leuint - the int representation of the little-endian
unsigned integer
uintpublic void addGameListener(GameListener l)
GameListener to receive events from this source.
addGameListener in interface GameEventSourcepublic void removeGameListener(GameListener l)
removeGameListener in interface GameEventSourcepublic void fireGameEvent(GameEvent ge)
fireGameEvent in interface GameEventSourcege - the game event to fire
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||