Package pacManReloaded.client
Class ClientThread
- java.lang.Object
-
- java.lang.Thread
-
- pacManReloaded.client.ClientThread
-
- All Implemented Interfaces:
java.lang.Runnable
public class ClientThread extends java.lang.Thread
-
-
Constructor Summary
Constructors Constructor Description ClientThread(Client _client, java.net.Socket _socket, java.lang.String myName)Constructor of ClientThread
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()closes the Thread - disconnects the Client from the serverlonggetLastContact()"getter" for last contact to the serverjava.lang.StringgetMyLobby()"getter" for your lobbyjava.lang.StringgetMyName()"getter" for your namevoidhandleActorInit(java.lang.String paramValue)handles the "decision" of which player is going to be which type (PacMan or Ghost?)voidhandleActorPos(java.lang.String parm)method which handles the position and direction of the playersvoidhandleBeginFailed()handles the starting game failed message for the clientvoidhandleChat(ChatMessage chatMessage)handles the chat message, decides which type of message you want to sendvoidhandleChatToMeMessage(ChatWithAddress chatToMeMessage)handles the message, which was send to you (private message)voidhandleGameFinish(GameFinishedMessage gameFinishedMessage)voidhandleGameState(java.lang.String paramValue)handles the state of the game, containing scores and "superpower"voidhandleInitGameState(java.lang.String paramValue)initialization of the game statevoidhandleJoinLobbyResponse(java.lang.String lobbyResponseResult)handles to response of the lobby to your clientvoidhandleManual(java.lang.String paramValue)handles the manual for the clientvoidhandleMap(MapMessage mapMessage)handles the messages of the map, containing walls, balls, ...voidhandleRemoveObject(java.lang.String paramValue)method which handles the removing of an object, which was taken buy a player from the field, deletes the object from the client GUIvoidhandleServerClientInfo(java.lang.String serverInfo)handles the info of the server, and prints itvoidhandleServerHighScore(java.lang.String paramValue)handles the reading of the highscore file by the servervoidhandleServerLobbyInfo(java.lang.String serverInfo)handles the info of the server, and prints itvoidrun()run method listens to the input stream, processes the data that it receivesvoidsend(IMessage msg)method to send the messagevoidsetMyLobby(java.lang.String myLobby)"setter" for your lobbyvoidsetMyName(java.lang.String myName)sets the name of the clientvoidupdateLastContact()updates the last contact of the client to the server in milliseconds-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
Constructor Detail
-
ClientThread
public ClientThread(Client _client, java.net.Socket _socket, java.lang.String myName)
Constructor of ClientThread- Parameters:
_client- name of the client_socket- name of the socketmyName- nickname of the player
-
-
Method Detail
-
run
public void run()
run method listens to the input stream, processes the data that it receives- Specified by:
runin interfacejava.lang.Runnable- Overrides:
runin classjava.lang.Thread
-
send
public void send(IMessage msg)
method to send the message- Parameters:
msg- message to be send
-
close
public void close()
closes the Thread - disconnects the Client from the server
-
handleChat
public void handleChat(ChatMessage chatMessage)
handles the chat message, decides which type of message you want to send- Parameters:
chatMessage- message you want to send
-
handleMap
public void handleMap(MapMessage mapMessage)
handles the messages of the map, containing walls, balls, ...- Parameters:
mapMessage- information about the map
-
handleActorPos
public void handleActorPos(java.lang.String parm)
method which handles the position and direction of the players- Parameters:
parm- information of the players position
-
handleActorInit
public void handleActorInit(java.lang.String paramValue)
handles the "decision" of which player is going to be which type (PacMan or Ghost?)- Parameters:
paramValue- information about the initialization of the players
-
handleChatToMeMessage
public void handleChatToMeMessage(ChatWithAddress chatToMeMessage)
handles the message, which was send to you (private message)- Parameters:
chatToMeMessage- message which you ("me") receive by another client/player
-
handleServerLobbyInfo
public void handleServerLobbyInfo(java.lang.String serverInfo)
handles the info of the server, and prints it- Parameters:
serverInfo- info of the server
-
handleServerClientInfo
public void handleServerClientInfo(java.lang.String serverInfo)
handles the info of the server, and prints it- Parameters:
serverInfo- info of the server
-
handleJoinLobbyResponse
public void handleJoinLobbyResponse(java.lang.String lobbyResponseResult)
handles to response of the lobby to your client- Parameters:
lobbyResponseResult- response of the lobby to the client
-
handleServerHighScore
public void handleServerHighScore(java.lang.String paramValue)
handles the reading of the highscore file by the server- Parameters:
paramValue- the highscore as a string
-
handleManual
public void handleManual(java.lang.String paramValue)
handles the manual for the client- Parameters:
paramValue- the manual as string
-
handleInitGameState
public void handleInitGameState(java.lang.String paramValue)
initialization of the game state- Parameters:
paramValue- information about the initialization of the game state
-
handleGameState
public void handleGameState(java.lang.String paramValue)
handles the state of the game, containing scores and "superpower"- Parameters:
paramValue- information about the current game state
-
handleRemoveObject
public void handleRemoveObject(java.lang.String paramValue)
method which handles the removing of an object, which was taken buy a player from the field, deletes the object from the client GUI- Parameters:
paramValue- information about the initialisation of the players
-
handleBeginFailed
public void handleBeginFailed()
handles the starting game failed message for the client
-
handleGameFinish
public void handleGameFinish(GameFinishedMessage gameFinishedMessage)
-
updateLastContact
public void updateLastContact()
updates the last contact of the client to the server in milliseconds
-
getMyName
public java.lang.String getMyName()
"getter" for your name- Returns:
- your nickname
-
getLastContact
public long getLastContact()
"getter" for last contact to the server- Returns:
- time of the last contact to the server
-
setMyName
public void setMyName(java.lang.String myName)
sets the name of the client- Parameters:
myName- nickname of the client
-
getMyLobby
public java.lang.String getMyLobby()
"getter" for your lobby- Returns:
- lobby you are connected to
-
setMyLobby
public void setMyLobby(java.lang.String myLobby)
"setter" for your lobby- Parameters:
myLobby- lobby you want to be connected to
-
-