Package dev.forbit.server.interfaces
Interface ConnectionServer
- All Known Implementing Classes:
GSONTCPServer,GSONUDPServer,RawTCPServer,RawUDPServer,TCPServer,UDPServer
public interface ConnectionServer
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidbegin()Initialises the server and begins the loopGets the address to host the bind the server too.intgetPort()Get the portGets the parentServerobject that the packet was received ondefault StringReturns a GSON serialised string of the objectbooleaninit()Initialise the server.booleanReturns whether the server is currently runningvoidloop()The basic loop that happens every tickvoidsetRunning(boolean running)Sets the server running statusdefault voidshutdown()Sets running to falsevoidstart()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 parentServerobject 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
Initialises the server and begins the loop- Throws:
ServerInitialisationError- throws if there was an error in the initialisation phase.
-
getString
Returns a GSON serialised string of the object- Returns:
- GSON string
-