... | ... | @@ -137,7 +137,7 @@ catch (RemoteException e) { |
|
|
}
|
|
|
```
|
|
|
|
|
|
The requester is created by connecting to the responder named "the-responder" living in the "RespApp" application. Once connected, the requester can send requests and receive the responses. Here again the pre-condition for the creation of the requester is that *This* must have been initialized.
|
|
|
The requester is created by connecting to the responder named "the-responder" living in the *RespApp* application. Once connected, the requester can send requests and receive the responses. Here again the pre-condition for the creation of the requester is that *This* must have been initialized.
|
|
|
|
|
|
The requester application can terminate unexpectedly whereas the responder is responding to it. In that case the responder may block indefinitely. That is why it is possible to set a timeout in milliseconds:
|
|
|
```cpp
|
... | ... | @@ -191,7 +191,7 @@ std::unique_ptr<coms::Subscriber> subscriber = coms::Subscriber::create(*publish |
|
|
|
|
|
// Receive data.
|
|
|
while (true) {
|
|
|
std::optional<string> message = subscriber->receive();
|
|
|
std::optional<std::string> message = subscriber->receive();
|
|
|
|
|
|
// If there is no value then the subscriber will not receive message any more.
|
|
|
if (!message.has_value()) {
|
... | ... | @@ -200,4 +200,8 @@ while (true) { |
|
|
std::cout << "Received " << message.value() << std::endl;
|
|
|
}
|
|
|
```
|
|
|
The subscriber is created by connecting to the publisher named "the-publisher" living in the *PubApp* application. Once connected, the subscriber will receive the messages until an emty message arrives. Here again the pre-condition for the creation of the subscriber is that *This* must have been initialized.
|
|
|
|
|
|
As for the requester/responder no port was provided to define the publisher and subscriber. but only a name. Moreover the Cameo implementation provides a bit of synchronization with the number of subscribers which can be very useful.
|
|
|
|
|
|
The communication patterns provided by Cameo are high-level and allow programmers to rapidly design a communication between apps. |