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 void
close()
closes the Thread - disconnects the Client from the serverlong
getLastContact()
"getter" for last contact to the serverjava.lang.String
getMyLobby()
"getter" for your lobbyjava.lang.String
getMyName()
"getter" for your namevoid
handleActorInit(java.lang.String paramValue)
handles the "decision" of which player is going to be which type (PacMan or Ghost?)void
handleActorPos(java.lang.String parm)
method which handles the position and direction of the playersvoid
handleBeginFailed()
handles the starting game failed message for the clientvoid
handleChat(ChatMessage chatMessage)
handles the chat message, decides which type of message you want to sendvoid
handleChatToMeMessage(ChatWithAddress chatToMeMessage)
handles the message, which was send to you (private message)void
handleGameFinish(GameFinishedMessage gameFinishedMessage)
void
handleGameState(java.lang.String paramValue)
handles the state of the game, containing scores and "superpower"void
handleInitGameState(java.lang.String paramValue)
initialization of the game statevoid
handleJoinLobbyResponse(java.lang.String lobbyResponseResult)
handles to response of the lobby to your clientvoid
handleManual(java.lang.String paramValue)
handles the manual for the clientvoid
handleMap(MapMessage mapMessage)
handles the messages of the map, containing walls, balls, ...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 GUIvoid
handleServerClientInfo(java.lang.String serverInfo)
handles the info of the server, and prints itvoid
handleServerHighScore(java.lang.String paramValue)
handles the reading of the highscore file by the servervoid
handleServerLobbyInfo(java.lang.String serverInfo)
handles the info of the server, and prints itvoid
run()
run method listens to the input stream, processes the data that it receivesvoid
send(IMessage msg)
method to send the messagevoid
setMyLobby(java.lang.String myLobby)
"setter" for your lobbyvoid
setMyName(java.lang.String myName)
sets the name of the clientvoid
updateLastContact()
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:
run
in interfacejava.lang.Runnable
- Overrides:
run
in 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
-
-