Class Server
java.lang.Object
ch.nolix.base.net.level1server.AbstractServer
ch.nolix.base.net.level1server.Server
- All Implemented Interfaces:
IServer, Closeable, CloseStateRequestable, GroupCloseable, Clearable, EmptinessRequestable, AutoCloseable
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 Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic Serverstatic ServerforPort(int port) static ServerforPortAndInitialHttpMessage(int port, String initialHttpMessage) intgetPort()voidLets the currentGroupCloseablenote a close.Methods inherited from class AbstractServer
addDefaultSlot, addSlot, clear, containsDefaultSlot, containsSlotWithName, getStoredCloseController, isEmpty, removeSlotByNameMethods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface CloseStateRequestable
isOpenMethods inherited from interface EmptinessRequestable
containsAnyMethods inherited from interface GroupCloseable
close, createCloseDependencyTo, isClosed
-
Field Details
-
DEFAULT_INITIAL_HTTP_MESSAGE
- See Also:
-
-
Method Details
-
forHttpPort
- Returns:
- a new
Serverthat will listen toAbstractNetEndPoints on the HTTP port (80).
-
forPort
- Parameters:
port-- Returns:
- a new
Serverthat will listen toAbstractNetEndPoints on the given port. - Throws:
RuntimeException- if the given port is not in [0, 65535].
-
forPortAndInitialHttpMessage
- Parameters:
port-initialHttpMessage-- Returns:
- a new
Serverthat will listen toAbstractNetEndPoints on the given port. When a web browser connects to theServer, theServerwill 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
-
getPort
public int getPort()- Returns:
- the port of the current
Server.
-
getSecurityMode
-
noteClose
public void noteClose()Lets the currentGroupCloseablenote a close.
-