... | ... | @@ -41,4 +41,57 @@ Sequence of actions: |
|
|
* The application *App3* on *C* stops *App2*.
|
|
|
* The application *App1* and console are notified that *App2* stopped.
|
|
|
|
|
|
Let's see the code for each application. The application *App2* written in Java can look like:
|
|
|
|
|
|
```java
|
|
|
import fr.ill.ics.cameo.base.This;
|
|
|
|
|
|
public class JavaApp {
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
|
// Initialise the Cameo application represented by This.
|
|
|
This.init(args);
|
|
|
|
|
|
// Infinite printing loop.
|
|
|
int i = 0;
|
|
|
while (true) {
|
|
|
System.out.println("Printing " + i);
|
|
|
try {
|
|
|
Thread.sleep(100);
|
|
|
}
|
|
|
catch (InterruptedException e) {
|
|
|
}
|
|
|
i++;
|
|
|
}
|
|
|
|
|
|
This.terminate();
|
|
|
}
|
|
|
}
|
|
|
```
|
|
|
|
|
|
It simply prints a new line every 100ms infinitely. Notice that the name "App2" is the name of the application registered in the Cameo server so that there is no link with the class name.
|
|
|
|
|
|
The application *App1* written in C++ has the following lines:
|
|
|
|
|
|
```cpp
|
|
|
#include <cameo/api/cameo.h>
|
|
|
|
|
|
int main(int argc, char *argv[]) {
|
|
|
|
|
|
// Define the reference to the Cameo server in B.
|
|
|
cameo::Server server("tcp://B:7000");
|
|
|
|
|
|
// Start the application "App2" and obtain a reference to the running app.
|
|
|
std::unique_ptr<cameo::application::Instance> app2 = server.start("App2");
|
|
|
|
|
|
// Wait for the end of the app.
|
|
|
cameo::application::State state = app2->waitFor();
|
|
|
|
|
|
return 0;
|
|
|
}
|
|
|
```
|
|
|
|
|
|
It simply contacts the Cameo server in B and starts *App2* then waits for its termination.
|
|
|
|
|
|
The application *App3* written in Python has the following lines: |
|
|
\ No newline at end of file |