Class TCPServerClient

  • All Implemented Interfaces:
    Runnable

    public class TCPServerClient
    extends Object
    implements Runnable
    A client of a tcp server
    Author:
    Darius Dinger
    • Constructor Detail

      • TCPServerClient

        public TCPServerClient​(BufferedReader reader,
                               PrintWriter writer,
                               Socket socket,
                               String prefix,
                               PlayerGameObject player)
        Creating new client for a tcp server.
        Parameters:
        reader - Reader to listen from client messages
        writer - Writer to write to client
        socket - Socket of the client or null if no socket exist
        prefix - Prefix to identify the player in the network
        player - Player game object in the scene
    • Method Detail

      • getAddress

        public InetAddress getAddress()
        Returns:
        Host address of the client
      • isAlive

        public boolean isAlive()
        Returns:
        Is the client still connected
      • getPrefix

        public String getPrefix()
        Returns:
        Get player prefix/id to identify the player in the network
      • stop

        public void stop​(String message)
        Stopping clients connection to the server
        Parameters:
        message - Message to send to client before close
      • run

        public void run()
        Specified by:
        run in interface Runnable