... | ... | @@ -139,7 +139,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 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:
|
|
|
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
|
|
|
// Set the request timeout with 1s.
|
|
|
request->setTimeout(1000);
|
... | ... | @@ -152,7 +152,7 @@ if (!res) { |
|
|
```
|
|
|
This timeout can be set in Java and Python with the same method and function. But be careful, having a timeout does not mean that the reply was not received by the requester.
|
|
|
|
|
|
You can notice that no port was provided to define the requester and responder. Only a name was provided. The ports are assigned dynamically internally but the programmer does not have to care about.
|
|
|
You can notice that no port was provided to define the requester and responder. Only a name was provided. The **ports** are **assigned dynamically** internally but the programmer does not have to care about.
|
|
|
|
|
|
# Publisher/Subscriber
|
|
|
|
... | ... | @@ -178,8 +178,8 @@ catch (PublisherCreationException e) { |
|
|
}
|
|
|
```
|
|
|
|
|
|
Here again, *This* must have been initialized before creating the publisher. We provide a synchronization feature with the second argument of the *Publisher.create()* method: the number of subscribers can be provided. The call to *Publisher.waitForSubscribers()* is blocking until the required number of subscribers has been reached. This allows to have subscribers that will receive all the messages. The publisher is *synchronized*.
|
|
|
Default value is 0 and in that case *Publisher.waitForSubscribers()* immediately returns. Then the publisher is *not* synchronized and some messages will be lost.
|
|
|
Here again, *This* must have been initialized before creating the publisher. We provide a synchronization feature with the second argument of the *Publisher.create()* method: the number of subscribers can be provided. The call to *Publisher.waitForSubscribers()* is blocking until the required number of subscribers has been reached. This allows to have subscribers that will receive all the messages. The publisher is **synchronized**.
|
|
|
Default value is 0 and in that case *Publisher.waitForSubscribers()* immediately returns. Then the publisher is **not** synchronized and some messages will be lost.
|
|
|
|
|
|
Let's give an example of a subcriber in C++:
|
|
|
```cpp
|
... | ... | @@ -202,6 +202,6 @@ while (true) { |
|
|
```
|
|
|
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.
|
|
|
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. |
|
|
The communication patterns provided by Cameo are **high-level** and allow programmers to rapidly design a communication between apps. |