class Connection extends Endpoint
PathfinderServices.getConnection().| Modifier and Type | Field and Description |
|---|---|
private static org.slf4j.Logger |
logger
Logs actions performed by the class.
|
private MessageHandler |
messageHandler
Handles incoming web socket messages.
|
private Queue<String> |
messageQueue
Stores messages while the connection is down.
|
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.
|
| Modifier | Constructor and Description |
|---|---|
protected |
Connection()
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.
|
protected long |
getReceivedMessageCount()
Returns the number of messages receive through the web socket.
|
protected 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 |
onError(Session session,
Throwable throwable) |
void |
onOpen(Session session,
EndpointConfig config) |
private void |
send(String message)
Sends a message through the web socket connection to the Pathfinder server.
|
protected void |
sendAuthenticationMessage(String message)
Sends an authentication messages that bypasses the message queue.
|
void |
sendMessage(String message)
Sends a text message through the web socket to the Pathfinder server if connected.
|
protected void |
setMessageHandler(MessageHandler messageHandler)
Sets the web socket connection's message handler.
|
private static final org.slf4j.Logger logger
private Session session
private long sentMessageCount
private MessageHandler messageHandler
protected Connection()
protected void setMessageHandler(MessageHandler messageHandler)
AuthenticationMessageHandler it will attempt to send all
of the backed up messages until the user was authenticated.messageHandler - to receive the web socket messages.private void send(String message)
message - to be send.public void sendMessage(String message)
message - to be sent.protected void sendAuthenticationMessage(String message)
message - to send to the pathfinder server.public void onOpen(Session session, EndpointConfig config)
public void onClose(Session session, CloseReason closeReason)
public boolean isConnected()
protected long getSentMessageCount()
protected 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.