API¶
-
class
dpn::Peer¶ Peer Class.
The Peer class defines the basic unit of the peer network. A peer has a private instance of a Hub which it uses to interact with other peers.
Public Functions
-
void
Request(Label &label, Package &sendMessage, Package &recvMessage, Hub::HubTimeout timeout = Hub::HubTimeout(0))¶ RPC - Request.
Sends request to a remote peer’s reply interface. The Connection description is used to determine the remote peer and reply inteface to use. The contents of sendMessage should be set locally before the Request() call, and the contents of recvMessage are set remotely and accessible after the call.
The Request() will block until either a reply is received by the requested interface, or the timeout expires, whichever comes first.
- Parameters
connDesc: Connection Description; Dest peer ID and interface ID used to identify reply interfacesendMessage: Message send to reply interfacerecvMessage: Message received by reply interfacetimeout: Milliseconds to wait for recvMessage
-
void
Publish(Label &label, Package &package)¶ Pub/Sub - Publish.
Publishes data to subscription interfaces that are subscribed. The Connection description is used to determine the interface ID to publish on (interface ID is used as the topic). The contents of message should be set locally before calling Publish(). The contents will be sent to each subscription interface that has previously subscribed.
This call does not wait or expect any reply. It will return as soon as the message has been sent to each subscriber.
- Parameters
connDesc: Connection Description; Self Interface ID used as topicpackage: Package to be published
-
void
Push(Label &label, Package &package)¶ Push/Pull - Push.
Pushes data to a specified peer and pull interface. The Connection description is used to determine the remote peer and its pull interface. The contents of message should be set locally before calling Push(). The contents will be sent to the peer on its specifid pull inteface.
This call does not wait or expect any reply. It will return as soon as the message has been sent.
- Parameters
connDesc: Connection Description; Dest peer ID and interface ID used to identify pull interfacemessage: Message to be pushed
-
void
ServiceInterfaces(const Hub::HubTimeout timeout)¶ Service Interfaces - Handle pending messages for interfaces.
Checks for any pending/queued messages waiting to be read. If a message is found, the contents will be copied into the contents of the user supplied message. This message will then be forwarded to the appropriate interface according to the inteface specified in the header.
This call will block until either an interface is serviced, or until the timeout expires, whichever comes first.
- Parameters
timeout: Milliseconds to wait for pending message
-
void
GetPendingPackage(Label &label, Package &package, const Hub::HubTimeout &timeout)¶ Get Pending Message.
Checks for any pending/queued messages waiting to be read. If a message is found, the conents will be copied into the user supplied message. The function then returns, allowing the user to handle the data directly.
This call will block until either a message is read, or until the timeout expires, whichever comes first.
- Parameters
connDesc: Connection Description; Set by function to value in received message headermessage: Message used for storing contents of read queued messagetimeout: Milliseconds to wait for pending message
-
void