public class ClientConnection extends Object
| Constructor and Description |
|---|
ClientConnection()
Constructor.
|
ClientConnection(boolean streamMode)
Constructor, used to specify streaming mode if set.
|
| Modifier and Type | Method and Description |
|---|---|
ClientConnection |
authReceived(Consumer<ServerAuthResponseMessage> onAuthentication)
Lambda function called when an authentication message is received.
|
void |
connect(String endpointSent)
Connects to a specified address, in the format of "address" or "address:port".
|
void |
disconnect()
Handles the disconnection from the currently active client.
|
String |
getConnectStatus()
Returns the status of the current connection.
|
boolean |
isConnected()
Flag indicating whether or not the connection is active.
|
ClientConnection |
messageReceived(Consumer<JobMessage> onMessage)
Lambda function called when a message is received from the endpoint.
|
ClientConnection |
onConnect(Consumer<ClientConnectionState> onConnect)
Lambda function called when a connection has been established.
|
void |
sendMessage(byte[] data)
Sends a command payload to the server, packetizing the data (header with length), and sending it across the wire
in a
Buffer. |
ClientConnection |
streamReceived(Consumer<byte[]> onStream)
Lambda function called when a stream of byte data is received.
|
public ClientConnection()
public ClientConnection(boolean streamMode)
streamMode - true if streaming mode (port 10002), false otherwise for port 10001.public ClientConnection onConnect(Consumer<ClientConnectionState> onConnect)
onConnect - Consumer function that takes a ClientConnectionState indicating the connection state.public ClientConnection messageReceived(Consumer<JobMessage> onMessage)
onMessage - Consumer function that takes a JobMessage object.public ClientConnection streamReceived(Consumer<byte[]> onStream)
onStream - Consumer function that takes a byte[] array of data.public ClientConnection authReceived(Consumer<ServerAuthResponseMessage> onAuthentication)
onAuthentication - Consumer function that takes a ServerAuthResponseMessage object.public void connect(String endpointSent)
endpointSent - The endpoint address to connect to.public void disconnect()
public void sendMessage(byte[] data)
Buffer.data - A byte[] array of data to send.public String getConnectStatus()
String containing a human-readable representation of the connection status.public boolean isConnected()
true if the connection is active, false otherwise.Copyright © 2015. All rights reserved.