public class StreamClient extends Object
Packets are only sent to the onStream function as they are received in full. This API will buffer all data
from a connection.
Created by kenji on 2/8/15.
| Constructor and Description |
|---|
StreamClient() |
| Modifier and Type | Method and Description |
|---|---|
void |
addClient(String clientName,
String clientAddress)
Adds a connection to a server, assigning a name to that connection.
|
void |
closeStream(String clientName,
String streamId)
Unsubscribes from a stream by ID.
|
ClientConnection |
getClientConnection(String clientName)
Retrieves the underlying
ClientConnection, which is the communication layer to the endpoint. |
StreamClient |
onConnect(Consumer<String> function)
Lambda function called when a connection is successful.
|
StreamClient |
onDisconnect(Consumer<String> function)
Lambda function called when a connection is lost, or dropped.
|
StreamClient |
onStream(BiConsumer<String,byte[]> function)
Lambda function called when a stream packet is receive from a server.
|
void |
openStream(String clientName,
String streamId)
Subscribes to a stream by ID.
|
public void addClient(String clientName, String clientAddress)
clientName - The name of the connection to assign.clientAddress - The address to connect to.public ClientConnection getClientConnection(String clientName)
ClientConnection, which is the communication layer to the endpoint. This is available
for use if required.clientName - The name of the connection to retrieve.ClientConnection if found.public void openStream(String clientName, String streamId)
clientName - The client connection to connect to.streamId - String containing the stream ID.public void closeStream(String clientName, String streamId)
clientName - The client connection to connect to.streamId - String containing the stream ID.public StreamClient onConnect(Consumer<String> function)
function - The Consumer function to set.StreamClient object for command chaining.public StreamClient onDisconnect(Consumer<String> function)
function - The Consumer function to set.StreamClient object for command chaining.public StreamClient onStream(BiConsumer<String,byte[]> function)
function - The BiConsumer of streamId, byte[] data received from the server for the specified stream.StreamClient object for command chaining.Copyright © 2015. All rights reserved.