|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.lang.Thread
vooga.engine.networking.server.Handler
vooga.engine.networking.server.ChatHandler
public class ChatHandler
Class that handles communicating through chats over the network. There is one instance of ChatHandler for each time the game is run and a static list of the current running ChatHandlers. ChatHandler extends the Handler class so it also extends Thread and has a socket to send and receive chats through as well as a session ID to group ChatHandlers that are part of the same game session.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class java.lang.Thread |
---|
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler |
Field Summary | |
---|---|
protected static java.util.List<ChatHandler> |
handlers
|
Fields inherited from class vooga.engine.networking.server.Handler |
---|
sessionID, socket |
Fields inherited from class java.lang.Thread |
---|
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY |
Constructor Summary | |
---|---|
ChatHandler(GameSocket socket,
int sessionID)
Initializes ChatHandler with a socket to send and receive chats through and the chat's game session ID. |
Method Summary | |
---|---|
protected static void |
broadcast(java.lang.String chat,
ChatHandler sender)
Broadcast (send) the chat to everyone connected to this handler's game session besIDes the sender. |
void |
run()
When the thread starts, add this handler to the game's list of ChatHandlers, then keep looking for messages to read from the socket and send out to all the players. |
Methods inherited from class vooga.engine.networking.server.Handler |
---|
getSessionID, getSocket |
Methods inherited from class java.lang.Thread |
---|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static java.util.List<ChatHandler> handlers
Constructor Detail |
---|
public ChatHandler(GameSocket socket, int sessionID)
socket
- the socket to send and receive chats throughsessionID
- the ID of the chat's game sessionMethod Detail |
---|
public void run()
run
in interface java.lang.Runnable
run
in class Handler
protected static void broadcast(java.lang.String chat, ChatHandler sender)
chat
- the chat to send to the other playerssender
- the handler who is sending the chat
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |