Class TCPServer

  • All Implemented Interfaces:
    Runnable

    public class TCPServer
    extends Object
    implements Runnable
    Server class for a tcp connection
    Author:
    Darius Dinger
    • Constructor Detail

      • TCPServer

        public TCPServer()
    • Method Detail

      • isFull

        public static boolean isFull()
        Returns:
        Is the server full
      • clientCount

        public static int clientCount()
        Returns:
        How many clients are currently connected to the server
      • banClient

        public static void banClient​(int id,
                                     String message)
        Banning client from the server
        Parameters:
        id - Client id to ban
        message - Message to send by banning
      • kickClient

        public static void kickClient​(int id,
                                      String message)
        Kicking client from the server
        Parameters:
        id - Client id to kick
        message - Message to send by kicking
      • addBannedAddress

        public static void addBannedAddress​(InetAddress addr)
        Parameters:
        addr - Address to ban
      • getMaxPlayers

        public static int getMaxPlayers()
        Returns:
        Max player count of the server
      • getClients

        public static TCPServerClient[] getClients()
        Getting an array of all clients that are connected to the server. The id if the array is the id of the client. Ifa client at id x is equal to null, thn the id x has still no client!
        Returns:
        Array of the connected clients
      • run

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