public class Server extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
INITIAL_SESSIONS_NUMBER |
| Constructor and Description |
|---|
Server(Listener listener,
IFeatureRepository featureRepository,
IPromiseRepository promiseRepository)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close all connections and stop listening for clients.
|
void |
closeSession(UUID sessionIndex)
Close connection to a client
|
boolean |
isSessionOpen(UUID sessionIndex) |
void |
open(String hostname,
int port,
ServerEvents serverEvents)
Start listening for clients.
|
CompletableFuture<Confirmation> |
send(UUID sessionIndex,
Request request)
Send a message to a client.
|
public static final int INITIAL_SESSIONS_NUMBER
public Server(Listener listener, IFeatureRepository featureRepository, IPromiseRepository promiseRepository)
listener - injected listener.public void open(String hostname, int port, ServerEvents serverEvents)
hostname - Url or IP of the server as String.port - the port number of the server.serverEvents - Callback handler for server specific events.public void close()
public CompletableFuture<Confirmation> send(UUID sessionIndex, Request request) throws UnsupportedFeatureException, OccurenceConstraintException, NotConnectedException
sessionIndex - Session index of the client.request - Request for the client.UnsupportedFeatureException - Thrown if the feature isn't among the list of supported
featured.OccurenceConstraintException - Thrown if the request isn't valid.NotConnectedExceptionpublic boolean isSessionOpen(UUID sessionIndex)
public void closeSession(UUID sessionIndex)
sessionIndex - Session index of the client.Copyright © 2022. All rights reserved.