Session¶
-
public class
Session
¶ A zenoh-net session.
Methods¶
close¶
-
public void
close
()¶ Close the zenoh-net session.
Throws: - ZException – if close failed.
declareEval¶
-
public Eval
declareEval
(String resource, QueryHandler handler)¶ Declare an eval able to provide data matching the provided resource name resource.
Parameters: - resource – the resource to evaluate.
- handler – a
QueryHandler
subclass implementing the the callback function that will be called each time a query for data matching the evaluated resource name resource is received. TheQueryHandler.handleQuery(String,String,RepliesSender)
function MUST call the providedRepliesSender.sendReplies(Resource[])
function with the resulting data.RepliesSender.sendReplies(Resource[])
can be called with an empty array.
Throws: - ZException – if declaration fails.
Returns: the Eval.
declarePublisher¶
-
public Publisher
declarePublisher
(String resource)¶ Declare a publication for resource name resource.
Parameters: - resource – the resource name to publish.
Throws: - ZException – if declaration fails.
Returns: the zenoh
Publisher
.
declareStorage¶
-
public Storage
declareStorage
(String resource, StorageHandler handler)¶ Declare a storage for all data matching the provided resource name resource.
Parameters: - resource – the resource selection to store.
- handler – a
StorageHandler
subclass implementing the callback functions that will be called each time a data matching the stored resource name resource is received and each time a query for data matching the stored resource name resource is received. TheStorageHandler.handleQuery(String,String,RepliesSender)
function MUST call the providedRepliesSender.sendReplies(Resource[])
function with the resulting data.RepliesSender.sendReplies(Resource[])
can be called with an empty array.
Throws: - ZException – if declaration fails.
Returns: the zenoh
Storage
.
declareSubscriber¶
-
public Subscriber
declareSubscriber
(String resource, SubMode mode, DataHandler handler)¶ Declare a subscribtion for all published data matching the provided resource name resource.
Parameters: - resource – the resource name to subscribe to.
- mode – the subscription mode.
- handler – a
DataHandler
subclass implementing the callback function that will be called each time a data matching the subscribed resource name resource is received.
Throws: - ZException – if declaration fails.
Returns: the zenoh-net
Subscriber
.
info¶
open¶
-
public static Session
open
(String locator)¶ Open a zenoh-net session.
Parameters: - locator – a string representing the network endpoint to which establish the session. A typical locator looks like this :
"tcp/127.0.0.1:7447"
. Ifnull
, open() will scout and try to establish the session automatically.
Throws: - ZException – if session etablishment fails.
Returns: a Zenoh object representing the openned zenoh session..
- locator – a string representing the network endpoint to which establish the session. A typical locator looks like this :
open¶
-
public static Session
open
(String locator, Map<Integer, byte[]> properties)¶ Open a zenoh-net session.
Parameters: - locator – a string representing the network endpoint to which establish the session. A typical locator looks like this :
"tcp/127.0.0.1:7447"
. Ifnull
, open() will scout and try to establish the session automatically. - properties – a map of properties that will be used to establish and configure the zenoh session. properties will typically contain the
"username"
and"password"
informations needed to establish the zenoh session with a secured infrastructure. It can be set tonull
.
Throws: - ZException – if session etablishment fails.
Returns: a Zenoh object representing the openned zenoh session..
- locator – a string representing the network endpoint to which establish the session. A typical locator looks like this :
query¶
-
public void
query
(String resource, String predicate, ReplyHandler handler)¶ Query data matching resource name resource.
Parameters: - resource – the resource to query.
- predicate – a string that will be propagated to the storages and evals that should provide the queried data. It may allow them to filter, transform and/or compute the queried data. .
- handler – a
ReplyHandler
subclass implementing the callback function that will be called on reception of the replies of the query.
Throws: - ZException – if fails.
query¶
-
public void
query
(String resource, String predicate, ReplyHandler handler, QueryDest dest_storages, QueryDest dest_evals)¶ Query data matching resource name resource.
Parameters: - resource – the resource to query.
- predicate – a string that will be propagated to the storages and evals that should provide the queried data. It may allow them to filter, transform and/or compute the queried data. .
- handler – a
ReplyHandler
subclass implementing the callback function that will be called on reception of the replies of the query. - dest_storages – a
QueryDest
indicating which matching storages should be destination of the query. - dest_evals – a
QueryDest
indicating which matching evals should be destination of the query.
Throws: - ZException – if fails.
writeData¶
-
public void
writeData
(String resource, java.nio.ByteBuffer payload)¶ Send data in a write_data message for the resource resource.
Parameters: - resource – the resource name of the data to be sent.
- payload – the data.
Throws: - ZException – if write fails.
writeData¶
-
public void
writeData
(String resource, java.nio.ByteBuffer payload, short encoding, short kind)¶ Send data in a write_data message for the resource resource.
Parameters: - resource – the resource name of the data to be sent.
- payload – the data.
- encoding – a metadata information associated with the published data that represents the encoding of the published data.
- kind – a metadata information associated with the published data that represents the kind of publication.
Throws: - ZException – if write fails.