... | ... | @@ -48,25 +48,25 @@ import fr.ill.ics.cameo.base.This; |
|
|
|
|
|
public class JavaApp {
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
public static void main(String[] args) {
|
|
|
|
|
|
// Initialise the Cameo application represented by This.
|
|
|
This.init(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();
|
|
|
}
|
|
|
// Infinite printing loop.
|
|
|
int i = 0;
|
|
|
while (true) {
|
|
|
System.out.println("Printing " + i);
|
|
|
try {
|
|
|
Thread.sleep(100);
|
|
|
}
|
|
|
catch (InterruptedException e) {
|
|
|
}
|
|
|
i++;
|
|
|
}
|
|
|
|
|
|
This.terminate();
|
|
|
}
|
|
|
}
|
|
|
```
|
|
|
|
... | ... | @@ -77,17 +77,23 @@ The application *App1* written in C++ has the following lines: |
|
|
|
|
|
```cpp
|
|
|
#include <cameo/api/cameo.h>
|
|
|
#include <iostream>
|
|
|
|
|
|
int main(int argc, char *argv[]) {
|
|
|
|
|
|
// Define the reference to the Cameo server in B.
|
|
|
cameo::Server server("tcp://B:7000");
|
|
|
// 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");
|
|
|
|
|
|
// 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 and get the terminal state.
|
|
|
cameo::application::State state = app2->waitFor();
|
|
|
|
|
|
// Wait for the end of the app and get the terminal state.
|
|
|
cameo::application::State state = app2->waitFor();
|
|
|
// Print the terminal state.
|
|
|
std::cout << "The application " << *app2
|
|
|
<< " terminated with state " << application::toString(state)
|
|
|
<< " and code " << app->getExitCode() << std::endl;
|
|
|
|
|
|
return 0;
|
|
|
}
|
... | ... | @@ -111,6 +117,10 @@ app2.stop() |
|
|
|
|
|
# Wait for the end of the app and get the terminal state.
|
|
|
state = app.waitFor()
|
|
|
|
|
|
print("The application", app2.getNameId(),
|
|
|
"terminated with state", cameopy.toString(state),
|
|
|
"and code", app2.getExitCode())
|
|
|
```
|
|
|
|
|
|
On computer *D*, the console connects to *App2* and receives some output before *App2* is stopped:
|
... | ... | @@ -126,3 +136,4 @@ The application App2.5 terminated successfully. |
|
|
```
|
|
|
|
|
|
The lines starting with *Connected* and *The application* are written by the console whereas the lines starting with *Printing* come from the app itself as it was configured to stream its error and output.
|
|
|
|