class Connection extends Endpoint
PathfinderServices.getConnection().| Modifier and Type | Field and Description |
|---|---|
private static org.slf4j.Logger |
logger |
private MessageHandler |
messageHandler
Handles incoming web socket messages.
|
private long |
sentMessageCount
Number of messages sent through the web socket.
|
private PathfinderServices |
services
Access to the model registry to notify
Models of incoming web socket messages. |
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 userCredentials)
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.
|
protected void |
setServices(PathfinderServices services)
Sets the pathfinder services object.
|
private static final org.slf4j.Logger logger
private final String userCredentials
private PathfinderServices services
Models of incoming web socket messages.private Session session
private long sentMessageCount
private MessageHandler messageHandler
protected Connection(String userCredentials)
userCredentials - the user's credentials for this applicationprotected void setServices(PathfinderServices services)
services - a pathfinder services objectpublic 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.