Class ClientThread

  • All Implemented Interfaces:
    java.lang.Runnable

    public class ClientThread
    extends java.lang.Thread
    • Nested Class Summary

      • Nested classes/interfaces inherited from class java.lang.Thread

        java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
    • Field Summary

      • Fields inherited from class java.lang.Thread

        MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
    • 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 server
      long getLastContact()
      "getter" for last contact to the server
      java.lang.String getMyLobby()
      "getter" for your lobby
      java.lang.String getMyName()
      "getter" for your name
      void 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 players
      void handleBeginFailed()
      handles the starting game failed message for the client
      void handleChat​(ChatMessage chatMessage)
      handles the chat message, decides which type of message you want to send
      void 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 state
      void handleJoinLobbyResponse​(java.lang.String lobbyResponseResult)
      handles to response of the lobby to your client
      void handleManual​(java.lang.String paramValue)
      handles the manual for the client
      void 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 GUI
      void handleServerClientInfo​(java.lang.String serverInfo)
      handles the info of the server, and prints it
      void handleServerHighScore​(java.lang.String paramValue)
      handles the reading of the highscore file by the server
      void handleServerLobbyInfo​(java.lang.String serverInfo)
      handles the info of the server, and prints it
      void run()
      run method listens to the input stream, processes the data that it receives
      void send​(IMessage msg)
      method to send the message
      void setMyLobby​(java.lang.String myLobby)
      "setter" for your lobby
      void setMyName​(java.lang.String myName)
      sets the name of the client
      void 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
      • Methods inherited from class java.lang.Object

        equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • 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 socket
        myName - 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 interface java.lang.Runnable
        Overrides:
        run in class java.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
      • 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