public interface Server
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(ServerListener listener)
Adds a listener to this server.
|
AbstractServer |
bind()
Binds the listener to its host and port.
|
AbstractServer |
bind(boolean wait)
Binds the listener to its host and port.
|
AbstractServer |
bind(boolean wait,
Runnable callback)
Binds the listener to its host and port.
|
void |
close()
Closes the listener.
|
void |
close(boolean wait)
Closes the listener.
|
void |
close(boolean wait,
Runnable callback)
Closes the listener.
|
<T> T |
getGlobalFlag(String key)
Gets the value of the given flag as an instance of the given type.
|
<T> T |
getGlobalFlag(String key,
T def)
Gets the value of the given flag as an instance of the given type.
|
Map<String,Object> |
getGlobalFlags()
Gets this server's set flags.
|
String |
getHost()
Gets the host the session is listening on.
|
List<ServerListener> |
getListeners()
Gets the listeners listening on this session.
|
Class<? extends PacketProtocol> |
getPacketProtocol()
Gets the packet protocol of the server.
|
int |
getPort()
Gets the port the session is listening on.
|
List<Session> |
getSessions()
Gets all sessions belonging to this server.
|
boolean |
hasGlobalFlag(String key)
Checks whether this server has a flag set.
|
boolean |
isListening()
Returns true if the listener is listening.
|
void |
removeListener(ServerListener listener)
Removes a listener from this server.
|
void |
setGlobalFlag(String key,
Object value)
Sets the value of a flag.
|
String getHost()
int getPort()
Class<? extends PacketProtocol> getPacketProtocol()
boolean isListening()
Map<String,Object> getGlobalFlags()
boolean hasGlobalFlag(String key)
key - Key of the flag to check for.<T> T getGlobalFlag(String key)
T - Type of the flag.key - Key of the flag.IllegalStateException - If the flag's value isn't of the required type.<T> T getGlobalFlag(String key, T def)
T - Type of the flag.key - Key of the flag.def - Default value of the flag.IllegalStateException - If the flag's value isn't of the required type.void setGlobalFlag(String key, Object value)
key - Key of the flag.value - Value to set the flag to.List<ServerListener> getListeners()
void addListener(ServerListener listener)
listener - Listener to add.void removeListener(ServerListener listener)
listener - Listener to remove.List<Session> getSessions()
AbstractServer bind()
AbstractServer bind(boolean wait)
wait - Whether to wait for the listener to finish binding.AbstractServer bind(boolean wait, Runnable callback)
wait - Whether to wait for the listener to finish binding.callback - Callback to call when the listener has finished binding.void close()
void close(boolean wait)
wait - Whether to wait for the listener to finish closing.void close(boolean wait,
Runnable callback)
wait - Whether to wait for the listener to finish closing.callback - Callback to call when the listener has finished closing.Copyright © 2021. All rights reserved.