java.lang.Object
java.util.Observable
Model.HostServer
-
Constructor Summary
ConstructorsConstructorDescriptionHostServer(int myPort, ClientHandler ch, String gameServerIp, int gameServerPort) HostServer constructor --> create a new HostServer. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSocket --> add a socket to the clientsSockets mapvoidclose()close --> close the server and all the socketsvoidsendToAllPlayers(int playerID, String methodName, String output) sendToAllPlayers --> send a message to all playersvoidsendToAllPlayers(String message) sendToBookScrabbleServer(String type, String word) sendToGameServer --> send a query or a challenge to the game servervoidsendToSpecificPlayer(int playerId, String message) voidsendToSpecificPlayer(int playerID, String methodName, String output) sendToSpecificPlayer --> send a message to a specific playervoidvoidstartServer --> start the server in a threadvoidstop()Methods inherited from class java.util.Observable
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers
-
Constructor Details
-
HostServer
HostServer constructor --> create a new HostServer.- Parameters:
myPort- --> the port of the HostServergameServerIp- --> the ip of the game servergameServerPort- --> the port of the game server
-
-
Method Details
-
getBookNames
-
startServer
public void startServer()startServer --> start the server in a thread -
stop
public void stop() -
close
public void close()close --> close the server and all the sockets -
addSocket
addSocket --> add a socket to the clientsSockets map- Parameters:
id- --> the id of the Playersocket- --> the socket of the Player
-
sendToBookScrabbleServer
sendToGameServer --> send a query or a challenge to the game server- Parameters:
type- --> "Q" for query or "C" for challengeword- --> the word to be queried or challenged
-
sendToSpecificPlayer
sendToSpecificPlayer --> send a message to a specific player- Parameters:
playerID- --> the id of the playermethodName- --> the method to notify the players aboutoutput- --> the output of the method
-
sendToSpecificPlayer
-
sendToAllPlayers
sendToAllPlayers --> send a message to all players- Parameters:
playerID- --> the id of the player to notify aboutmethodName- --> the method to notify the players aboutoutput- --> the output of the method
-
sendToAllPlayers
-
setChanged
public void setChanged()- Overrides:
setChangedin classObservable
-