Package dev.forbit.server.interfaces
Interface ServerInterface
- All Known Implementing Classes:
GSONServer
,RawServer
,Server
public interface ServerInterface
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a client to this list.getClient(SocketAddress address)
Get the client from a given SocketAddress.getClient(SocketChannel channel)
Get the client from a given SocketChannel.Get client from a given UUIDReturns the scheduler object, or optional.null if not created yetGets the Server Properties to load the server onReturns the TCP Server instanceint
How many milliseconds we should wait before force disconnecting the client from the server.Returns the UDP Server instancevoid
init()
Method called when booting up the server.void
Fired when a client is registered on the TCP and UDP server.void
onDisconnect(Client client)
Fired when the client disconnects from the server.boolean
removeClient(Client client)
Remove the client from the Server's list.void
sendPacketTCP(Client client, Packet packet)
Send a packet to the client.void
sendPacketUDP(Client client, Packet packet)
void
setServerProperties(ServerProperties properties)
Sets the Server Properties instancevoid
setTCPServer(TCPServer server)
Set the TCP Server instancevoid
setUDPServer(UDPServer server)
Set the UDP Server instancevoid
shutdown()
Shutdown all the servers.void
Update the client set, removing inactive clients if required.
-
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
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
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
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
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
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
Set the UDP Server instance- Parameters:
server
- server to set
-
getTCPServer
TCPServer getTCPServer()Returns the TCP Server instance- Returns:
- tcp server instance
-
setTCPServer
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
Sets the Server Properties instance- Parameters:
properties
- properties to set
-
onConnect
Fired when a client is registered on the TCP and UDP server.Client should have a Channel and an Address.
- Parameters:
client
-
-
onDisconnect
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
Send a packet to the client.Defaults to TCP.
- Parameters:
client
- clientpacket
- packet.
-
sendPacketUDP
-
getScheduler
Returns the scheduler object, or optional.null if not created yet- Returns:
- scheduler
-