java.lang.Object
nl.andrewl.concord_server.ConcordServer
- All Implemented Interfaces:
Runnable
The main server implementation, which handles accepting new clients.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ChannelManager
Manager that handles the collection of channels in this server.private final ClientManager
Manager that handles the collection of clients connected to this server.private final ServerConfig
Server configuration data.private static final Path
The path to this server's configuration file.private static final Path
The path to this server's database file.private final org.dizitart.no2.Nitrite
The database that contains all messages and other server information.private final DiscoveryServerPublisher
private final EventManager
Manager that handles incoming messages and events by clients.private final ExecutorService
A general-purpose executor service that can be used to submit async tasks.private final IdProvider
The component that generates new user and channel ids.private boolean
Running flag that's used to signal this server's thread to shutdown.private final ScheduledExecutorService
private final nl.andrewl.concord_core.msg.Serializer
A utility serializer that's mostly used when preparing a message to broadcast to a set of users, which is more efficient than having each individual client thread serialize the same message before sending it.private final ServerSocket
This server's socket, used to accept new client connections. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionnl.andrewl.concord_core.msg.types.ServerMetaData
boolean
static void
void
run()
private void
shutdown()
Shuts down the server cleanly by doing the following things: Disconnecting all clients. Shutting down any executor services. Flushing and compacting the message database. Flushing the server configuration one last time.void
stop()
Stops the server.
-
Field Details
-
CONFIG_FILE
The path to this server's configuration file. -
DATABASE_FILE
The path to this server's database file. -
running
private volatile boolean runningRunning flag that's used to signal this server's thread to shutdown. -
serverSocket
This server's socket, used to accept new client connections. -
serializer
private final nl.andrewl.concord_core.msg.Serializer serializerA utility serializer that's mostly used when preparing a message to broadcast to a set of users, which is more efficient than having each individual client thread serialize the same message before sending it. -
config
Server configuration data. This is used to define channels, discovery server addresses, and more. -
idProvider
The component that generates new user and channel ids. -
db
private final org.dizitart.no2.Nitrite dbThe database that contains all messages and other server information. -
executorService
A general-purpose executor service that can be used to submit async tasks. -
eventManager
Manager that handles incoming messages and events by clients. -
channelManager
Manager that handles the collection of channels in this server. -
clientManager
Manager that handles the collection of clients connected to this server. -
discoveryServerPublisher
-
scheduledExecutorService
-
-
Constructor Details
-
ConcordServer
- Throws:
IOException
-
-
Method Details
-
isRunning
public boolean isRunning()- Returns:
- True if the server is currently running, meaning it is accepting connections, or false otherwise.
-
stop
public void stop()Stops the server. Has no effect if the server has not started yet or has already been stopped. -
getMetaData
public nl.andrewl.concord_core.msg.types.ServerMetaData getMetaData()- Returns:
- The server's metadata.
-
shutdown
private void shutdown()Shuts down the server cleanly by doing the following things:- Disconnecting all clients.
- Shutting down any executor services.
- Flushing and compacting the message database.
- Flushing the server configuration one last time.
-
run
public void run() -
main
- Throws:
IOException
-