Interface ServerInterface

All Known Implementing Classes:
GSONServer, RawServer, Server

public interface ServerInterface
  • Method Details

    • init

      void init()
      Method called when booting up the server.

      Use this to start the thread if your server is extending Thread

    • shutdown

      void shutdown()
      Shutdown all the servers.
    • updateClients

      void updateClients()
      Update the client set, removing inactive clients if required.
    • getClient

      Optional<Client> getClient(UUID id)
      Get client from a given UUID
      Parameters:
      id - the id of the client
      Returns:
      optional containing the client, or empty if it cannot be found
    • getClient

      Optional<Client> getClient(SocketChannel channel)
      Get the client from a given SocketChannel.
      Parameters:
      channel - the channel of the client
      Returns:
      optional containing the client, or empty if it cannot be found
    • getClient

      Optional<Client> getClient(SocketAddress address)
      Get the client from a given SocketAddress.
      Parameters:
      address - the adress of the client.
      Returns:
      optional containing the client, or empty if it cannot be found.
    • removeClient

      boolean removeClient(Client client)
      Remove the client from the Server's list.
      Parameters:
      client - the client to remove
      Returns:
      whether or not the client was actually in the list.
    • addClient

      void addClient(Client client)
      Adds a client to this list.
      Parameters:
      client - the client to add
    • getUDPServer

      UDPServer getUDPServer()
      Returns the UDP Server instance
      Returns:
      udp server instance
    • setUDPServer

      void setUDPServer(UDPServer server)
      Set the UDP Server instance
      Parameters:
      server - server to set
    • getTCPServer

      TCPServer getTCPServer()
      Returns the TCP Server instance
      Returns:
      tcp server instance
    • setTCPServer

      void setTCPServer(TCPServer server)
      Set the TCP Server instance
      Parameters:
      server - server to set
    • getServerProperties

      ServerProperties getServerProperties()
      Gets the Server Properties to load the server on
      Returns:
      server properties instance
    • setServerProperties

      void setServerProperties(ServerProperties properties)
      Sets the Server Properties instance
      Parameters:
      properties - properties to set
    • onConnect

      void onConnect(Client client)
      Fired when a client is registered on the TCP and UDP server.

      Client should have a Channel and an Address.

      Parameters:
      client -
    • onDisconnect

      void onDisconnect(Client client)
      Fired when the client disconnects from the server.
      Parameters:
      client -
    • getTimeout

      int getTimeout()
      How many milliseconds we should wait before force disconnecting the client from the server.
      Returns:
      the timeout in milliseconds
    • sendPacketTCP

      void sendPacketTCP(Client client, Packet packet)
      Send a packet to the client.

      Defaults to TCP.

      Parameters:
      client - client
      packet - packet.
    • sendPacketUDP

      void sendPacketUDP(Client client, Packet packet)
    • getScheduler

      Optional<Scheduler> getScheduler()
      Returns the scheduler object, or optional.null if not created yet
      Returns:
      scheduler