|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectGameRoom
public class GameRoom
This is the GameRoom state that keeps track of a game's information and any messages that need to be relayed between clients in a game.
Field Summary |
---|
Fields inherited from interface Room |
---|
ADD_USER, CHAT, COLOR_CHANGE, CREATE, DRAW, END_SESSION, ERASE, ERROR, GAME_INFO, JOIN, LEAVE_GAME, LOGIN, LOGOUT, NEW_ILLUSTRATOR, REMOVE_USER, SIZE_CHANGE, START, STOP, TOPIC_REQUEST |
Constructor Summary | |
---|---|
GameRoom(Client firstPlayer,
MainRoom main)
Construct the GameRoom and specify a Client as illustrator. |
|
GameRoom(MainRoom main)
Construct the GameRoom |
Method Summary | |
---|---|
void |
addNewClient(Client newClient)
Adds a new client to the set of current clients If the client is the first to be added to the room that client is set as the first illustrator Sends a message to each client in the game room giving the name of the new client format of message: 101_userName_ |
boolean |
canJoin()
Determines whether a client can join the game room. |
boolean |
containsUser(java.lang.String userName)
Checks to see if a given user is in the room. |
int |
findUser(java.lang.String userName)
Looks through the array for a user. |
int |
getGameMode()
Returns the current game mode. |
Client |
getIllustrator()
Returns the currrent illustrator. |
int |
getNumPlayers()
Gets the number of players in the game room |
void |
handleMsg(java.lang.String msg,
Client sender)
Handles Messages from the client |
Client |
removeClient(java.lang.String userName)
Remove a client from the room. |
boolean |
sendTo(java.lang.String userName,
java.lang.String msg)
Sends a given message to a given user |
void |
sendToAllClients(java.lang.String message)
Sends a message to all clients. |
void |
sendToAllOthers(Client sender,
java.lang.String msg)
Sends a given message to all clients in the room except for the sender |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public GameRoom(MainRoom main)
main
- The main room that created this gamepublic GameRoom(Client firstPlayer, MainRoom main)
firstPlayer
- The client creating the room (illustrator)main
- The main room that created this gameMethod Detail |
---|
public int getNumPlayers()
public void addNewClient(Client newClient)
addNewClient
in interface Room
newClient
- The new client that is joining the serverpublic boolean canJoin()
public boolean sendTo(java.lang.String userName, java.lang.String msg)
userName
- The user namemsg
- The message being sent
public void sendToAllOthers(Client sender, java.lang.String msg)
sender
- The client who sent the messagemsg
- The message to be sentpublic void sendToAllClients(java.lang.String message)
message
- The message that is sent to every clientpublic Client removeClient(java.lang.String userName)
removeClient
in interface Room
userName
- The name of the client that is being removed
public void handleMsg(java.lang.String msg, Client sender)
handleMsg
in interface Room
msg
- the message or command that is being sentsender
- the client who sent the messagepublic boolean containsUser(java.lang.String userName)
containsUser
in interface Room
userName
- the user name to search for
public int findUser(java.lang.String userName)
userName
- User name to search for.public int getGameMode()
public Client getIllustrator()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |