Class Server

All Implemented Interfaces:
IServer, Closeable, CloseStateRequestable, GroupCloseable, Clearable, EmptinessRequestable, AutoCloseable

public final class Server extends AbstractServer
A Server is a AbstractServer that listens to AbstractNetEndPoint on a specific port. A Server supports the WebSocket protocol and can communicate with a WebSocket.
Author:
Silvan Wyss
  • Field Details

  • Method Details

    • forHttpPort

      public static Server forHttpPort()
      Returns:
      a new Server that will listen to AbstractNetEndPoints on the HTTP port (80).
    • forPort

      public static Server forPort(int port)
      Parameters:
      port -
      Returns:
      a new Server that will listen to AbstractNetEndPoints on the given port.
      Throws:
      RuntimeException - if the given port is not in [0, 65535].
    • forPortAndInitialHttpMessage

      public static Server forPortAndInitialHttpMessage(int port, String initialHttpMessage)
      Parameters:
      port -
      initialHttpMessage -
      Returns:
      a new Server that will listen to AbstractNetEndPoints on the given port. When a web browser connects to the Server, the Server will send the given initialHttpMessage to the web browser and close the connection.
      Throws:
      RuntimeException - if the given port is not in [0, 65535].
      RuntimeException - if the given initialHttpMessage is null.
      RuntimeException - if the given initialHttpMessage is blank.
    • getInitialHttpMessage

      public String getInitialHttpMessage()
      The HTTP message of a Server is the message a Server sends to web browsers.
      Returns:
      the initial HTTP message the current Server will send to web browsers.
    • getPort

      public int getPort()
      Returns:
      the port of the current Server.
    • getSecurityMode

      public SecurityMode getSecurityMode()
    • noteClose

      public void noteClose()
      Lets the current GroupCloseable note a close.