Interface ConnectionServer

All Known Implementing Classes:
GSONTCPServer, GSONUDPServer, RawTCPServer, RawUDPServer, TCPServer, UDPServer

public interface ConnectionServer
Defines common methods across Connection Servers see TCPServer and UDPServer
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    Initialises the server and begins the loop
    Gets the address to host the bind the server too.
    int
    Get the port
    Gets the parent Server object that the packet was received on
    default String
    Returns a GSON serialised string of the object
    boolean
    Initialise the server.
    boolean
    Returns whether the server is currently running
    void
    The basic loop that happens every tick
    void
    setRunning​(boolean running)
    Sets the server running status
    default void
    Sets running to false
    void
    Start the server
  • Method Details

    • start

      void start()
      Start the server
    • getPort

      int getPort()
      Get the port
      Returns:
      port to host server on
    • getServer

      Server getServer()
      Gets the parent Server object that the packet was received on
      Returns:
      Server that packet was received on
    • getAddress

      String getAddress()
      Gets the address to host the bind the server too.
      Returns:
      Address to host on.
    • shutdown

      default void shutdown()
      Sets running to false
    • isRunning

      boolean isRunning()
      Returns whether the server is currently running
      Returns:
      true if running
    • setRunning

      void setRunning(boolean running)
      Sets the server running status
      Parameters:
      running - running status
    • init

      boolean init()
      Initialise the server.
      Returns:
      false if an error occured
    • loop

      void loop()
      The basic loop that happens every tick
    • begin

      default void begin() throws ServerInitialisationError
      Initialises the server and begins the loop
      Throws:
      ServerInitialisationError - throws if there was an error in the initialisation phase.
    • getString

      default String getString()
      Returns a GSON serialised string of the object
      Returns:
      GSON string