private class InternalServer.ServerThread
extends java.lang.Thread
Modifier and Type | Field and Description |
---|---|
private java.util.Map<java.lang.Integer,Connection> |
connections
Map of active connections indexed by player ID.
|
private java.util.concurrent.ExecutorService |
executor
Executor service used to handle incoming connections.
|
private int |
nextID
The ID to assign to the next valid player.
|
private boolean |
running
Whether the server is running and accepting new connections.
|
private java.net.ServerSocket |
server
Main server socket.
|
Modifier | Constructor and Description |
---|---|
private |
ServerThread()
Constructs a new server thread.
|
Modifier and Type | Method and Description |
---|---|
private void |
broadCast(Packet packet)
Broadcasts a packet to all connected players.
|
private void |
broadCast(Player source,
Packet packet)
Broadcasts a packet to all connected players
except for the given source player.
|
private void |
close()
Closes all connections held by this server thread.
|
private void |
handleClient(java.net.Socket socket)
Handles an incoming client connection.
|
void |
run() |
private void |
shutdown()
Shuts down the part of this server responsible
for accepting incoming players.
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
private java.util.concurrent.ExecutorService executor
private java.net.ServerSocket server
private java.util.Map<java.lang.Integer,Connection> connections
private volatile boolean running
private volatile int nextID
private void close()
private void broadCast(Player source, Packet packet)
source
- The player to exclude.packet
- The packet to send.private void broadCast(Packet packet)
packet
- The packet to send.private void shutdown()
private void handleClient(java.net.Socket socket)
socket
- The client socket.public void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread