| Constructor and Description |
|---|
AbstractServer(String host,
int port,
Class<? extends PacketProtocol> protocol) |
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(ServerListener listener)
Adds a listener to this server.
|
void |
addSession(Session session) |
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.
|
void |
removeListener(ServerListener listener)
Removes a listener from this server.
|
void |
removeSession(Session session) |
void |
setGlobalFlag(String key,
Object value)
Sets the value of a flag.
|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitisListeningpublic AbstractServer(String host, int port, Class<? extends PacketProtocol> protocol)
public String getHost()
Serverpublic int getPort()
Serverpublic Class<? extends PacketProtocol> getPacketProtocol()
ServergetPacketProtocol in interface Serverpublic Map<String,Object> getGlobalFlags()
ServergetGlobalFlags in interface Serverpublic boolean hasGlobalFlag(String key)
ServerhasGlobalFlag in interface Serverkey - Key of the flag to check for.public <T> T getGlobalFlag(String key)
ServergetGlobalFlag in interface ServerT - Type of the flag.key - Key of the flag.public <T> T getGlobalFlag(String key, T def)
ServergetGlobalFlag in interface ServerT - Type of the flag.key - Key of the flag.def - Default value of the flag.public void setGlobalFlag(String key, Object value)
ServersetGlobalFlag in interface Serverkey - Key of the flag.value - Value to set the flag to.public List<ServerListener> getListeners()
ServergetListeners in interface Serverpublic void addListener(ServerListener listener)
ServeraddListener in interface Serverlistener - Listener to add.public void removeListener(ServerListener listener)
ServerremoveListener in interface Serverlistener - Listener to remove.public List<Session> getSessions()
ServergetSessions in interface Serverpublic void addSession(Session session)
public void removeSession(Session session)
public AbstractServer bind()
Serverpublic AbstractServer bind(boolean wait)
Serverpublic AbstractServer bind(boolean wait, Runnable callback)
Serverpublic void close()
Serverpublic void close(boolean wait)
ServerCopyright © 2021. All rights reserved.