class Connection extends Endpoint
PathfinderServices.getConnection().| Modifier and Type | Field and Description |
|---|---|
private String |
applictionIdentifier
The application identifier sent to the Pathfinder server.
|
private static Logger |
logger
Logs all outgoing messages through the web socket.
|
private MessageHandler |
messageHandler
Handles incoming web socket messages.
|
private ModelRegistry |
registry
Access to the model registry to notify
Models of incoming web socket messages. |
private long |
sentMessageCount
Number of messages sent through the web socket.
|
private Session |
session
The web socket session used to send messages through the web socket.
|
private String |
userCredentials
The user's credentials to the Pathfinder server.
|
| Modifier | Constructor and Description |
|---|---|
protected |
Connection(String applictionIdentifier,
String userCredentials,
ModelRegistry registry)
Constructs a connection object that controls access to the web socket connection
with the Pathfinder Server.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close(CloseReason reason)
Closes the web socket connection with the Pathfinder server.
|
long |
getReceivedMessageCount()
Returns the number of messages receive through the web socket.
|
long |
getSentMessageCount()
Returns the number of messages sent through the web socket.
|
boolean |
isConnected()
Returns if the web socket is connected.
|
void |
onClose(Session session,
CloseReason closeReason) |
void |
onOpen(Session session,
EndpointConfig config) |
void |
sendMessage(String message)
Sends a text message through the web socket to the Pathfinder server.
|
private final String applictionIdentifier
private final String userCredentials
private final ModelRegistry registry
Models of incoming web socket messages.private Session session
private long sentMessageCount
private MessageHandler messageHandler
private static final Logger logger
protected Connection(String applictionIdentifier, String userCredentials, ModelRegistry registry)
applictionIdentifier - the application identifier provided by the Pathfinder server for the applicationuserCredentials - the user's credentials for this applicationregistry - a model registrypublic void sendMessage(String message)
message - the message to be sent.IllegalStateException - the web socket is not connected.public void onOpen(Session session, EndpointConfig config)
public void onClose(Session session, CloseReason closeReason)
public boolean isConnected()
public long getSentMessageCount()
public long getReceivedMessageCount()
public void close(CloseReason reason) throws IOException
reason - the reason for closing the web socket.IOException - if the web socket failed to close properly.