
Java
1. Add the following code to your build file (build.gradle)
repositories {
maven {
url 'https://nexus.aethernet.io/repository/maven-releases/'
}
}
dependencies {
implementation 'io.aether:cloud-client:+'
}
2. Сreate two clients and wait for the registration to be completed
var aether1 = new AetherCloudClient().waitStart(10);
var aether2 = new AetherCloudClient().waitStart(10);
3. Configure receiving messages
var messageFuture = new ARFuture<String>();
aether1.onMessage((uid, msg) -> messageFuture.tryDone(new String(msg)));
4. Send a message to aether1
aether2.sendMessage(aether1.getUid(), "Hello World!".getBytes());
5. We are waiting for a message
if (messageFuture.waitDoneSeconds(10)) {
System.out.println("receive the message: " + messageFuture.get());
} else {
throw new IllegalStateException();
}
6. As a result, you should get this code in your file
import io.aether.cloud.client.AetherCloudClient;
import io.aether.utils.futures.ARFuture;
public class SomeJavaClass {
public static void main(String[] args) {
var aether1 = new AetherCloudClient().waitStart(10);
var aether2 = new AetherCloudClient().waitStart(10);
var messageFuture = new ARFuture<String>();
aether1.onMessage((uid, msg) -> messageFuture.tryDone(new String(msg)));
aether2.sendMessage(aether1.getUid(), "Hello World!".getBytes());
if (messageFuture.waitDoneSeconds(10)) {
System.out.println("receive the message: " + messageFuture.get());
} else {
throw new IllegalStateException();
}
}
}
TypeScript
1. Open a Terminal in Your Project Folder bash
cd /path/to/your/project
2. Initialize the Project
npm init -y
3. Add dependency to aether
npm install https://nexus.aethernet.io/repository/npm-private/cloud-client/-/cloud-client-latest.tgz
4. Install TypeScript & Node.js Type Definitions (if needed)
npm install typescript @types/node --save-dev
5. Initialize TypeScript Configuration
npx tsc --init
6. Create Project Structure
mkdir src
touch src/index.ts
7. Add Scripts to package.json
{
"scripts": {
"build": "tsc",
"start": "node dist/index.js",
"dev": "tsc --watch & nodemon dist/index.js"
}
}
8. Open the index.ts file
9. Сreate two clients and wait for the registration to be completed
const aether1 = await new AetherCloudClient().waitStart(10);
const aether2 = await new AetherCloudClient().waitStart(10);
10. Configure receiving messages
const messageFuture = new ARFuture<string>();
aether1.onMessage((uid: string, msg: Uint8Array) => {
messageFuture.tryDone(Buffer.from(msg).toString());
});
11. Send a message to aether1
aether2.sendMessage(aether1.getUid(), "Hello World!".getBytes());
12. We are waiting for a message
try {
const message = await messageFuture.waitDoneSeconds(10);
console.log("receive the message:", message);
} catch (e) {
throw new Error("Failed to receive message in time");
}
13. As a result, you should get this code in your file
import { AetherCloudClient } from 'io.aether.cloud.client';
import { ARFuture } from 'io.aether.utils.futures';
async function main() {
const aether1 = await new AetherCloudClient().waitStart(10);
const aether2 = await new AetherCloudClient().waitStart(10);
const messageFuture = new ARFuture<string>();
aether1.onMessage((uid: string, msg: Uint8Array) => {
messageFuture.tryDone(Buffer.from(msg).toString());
});
await aether2.sendMessage(aether1.getUid(), Buffer.from("Hello World!"));
try {
const message = await messageFuture.waitDoneSeconds(10);
console.log("receive the message:", message);
} catch (e) {
throw new Error("Failed to receive message in time");
}
}
main().catch(console.error);
C++
For integration your C++ code choose the platform you will use for Æthernet client. All available options listed below
Desktop
C++ Æthernet client library provided as a github repository which you are free to clone/submodule or copy near your project. We currently use CMake as a build system, but another popular one would be added in future.
1. Add an aether-cleint-cpp to your project as a submodule
git submodule add ‘https://github.com/aethernetio/aether-client-cpp.git’
2. Go to the aether-client-cpp and initialize it with script related to your system
cd aether-client-cpp; ./git_init.sh; cd ..
Use git_init.sh for Linux or macOS and git_init.bat or git_init.ps1 for Windows. It inits, updates and patches all third_party dependencies
3. Add Æther to your projects CMakeLists.txt
add_subdirectory(aether-client-cpp/aether aether)
4. By default Æther is built in production mode but for development purposes we need to set it up in distillation mode. Read about it in Documentation. Add to CMakeLists.txt
set(AE_DISTILLATION On)
5. Link your project with Æther
target_link_libraries(<your_target_name> PRIVATE aether)
6. Then in your code. Include “aether/aether_app.h” and create an Æthernet application
auto aether_app = ae::AetherApp::Construct({});
7. Register a few clients
constexpr auto parent_uid = ae::Uid::FromString(“<YOUR APPLICATION UID>”);Client::ptr aether1;
Client::ptr aether2;
ae::BarrierEvent<ae::Client::ptr, 2> clients_registered_event;
aether_app->aether()->RegisterClient(parent_uid)->ResultEvent([&](auto& register){clients_registered_event.Emit<0>(register.client()); });
aether_app->aether()->RegisterClient(parent_uid)->ResultEvent([&](auto& register){clients_registered_event.Emit<1>(register.client()); });
clients_registered_event.Subscribe([&]( auto const& ev){
aether1 = ev.Get<0>();
aether2 = ev.Get<1>();
});
8. Make a data stream to receive messages
auto stream1 = ae::make_unique<ae::P2pStream>(*aether_app->aether()->action_processor, aether1, aether2.uid());
stream1->out_data_event().Subscribe([&](std::vector<std::uint8_t> const& data){
/* ... handle your message … */
std::cout << “Received ” << std::string_view{data.data(), data.size()} << std::endl;
});
9. Make a data stream to send messages
auto stream2 = ae::make_unique<ae::P2pStream>(*aether_app->aether()->action_processor, aether2, aether1.uid()))
auto message= std::string_view{"Hello"};
stream2->Write({std::begin(message), std::end(message)});
10. And after all you need to integrate aether_app to yours or build a new event loop.
while(!aehter_app->IsExcited()){
auto next_time = aether_app->Update(ae::Now());
aether_app->WaitUntil(next_time);
}
For more full code and more examples see our examples repository
ESP IDF
C++ Æthernet client library provided as a github repository which you are free to clone/submodule or copy near your project.
1. Add an aether-cleint-cpp to your project as a submodule
git submodule add ‘https://github.com/aethernetio/aether-client-cpp.git’
2. Go to the aether-client-cpp and initialize it with script related to your system
cd aether-client-cpp; ./git_init.sh; cd ..
Use git_init.sh for Linux or macOS and git_init.bat or git_init.ps1 for Windows. It inits, updates and patches all third_party dependencies
3. Add Æther to your esp idf projects CMakeLists.txt as component
list(APPEND EXTRA_COMPONENT_DIRS "aether-client-cpp/aether”)
4. By default Æther is built in production mode but for development purposes we need to set up it in distillation mode. Read about it in Documentation. Add to CMakeLists.txt
set(AE_DISTILLATION On)
5. Require it for your component
idf_component_register(SRCS ${src_list}
INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}
PRIV_REQUIRES aether)
6. Then in your code. Include “aether/aether_app.h” and create an Æthernet application.
auto aether_app = ae::AetherApp::Construct({});
7. Register a few clients
constexpr auto parent_uid = ae::Uid::FromString(“<YOUR APPLICATION UID>”);
Client::ptr aether1;
Client::ptr aether2;
ae::BarrierEvent<ae::Client::ptr, 2> clients_registered_event;
aether_app->aether()->RegisterClient(parent_uid)->ResultEvent([&](auto& register){clients_registered_event.Emit<0>(register.client()); });
aether_app->aether()->RegisterClient(parent_uid)->ResultEvent([&](auto& register){clients_registered_event.Emit<1>(register.client()); });
clients_registered_event.Subscribe([&]( auto const& ev){
aether1 = ev.Get<0>();
aether2 = ev.Get<1>();
});
8. Make a data stream to receive messages
auto stream1 = ae::make_unique<ae::P2pStream>(*aether_app->aether()->action_processor, aether1, aether2.uid());
stream1->out_data_event().Subscribe([&](std::vector<std::uint8_t> const& data){
/* ... handle your message … */
std::cout << “Received ” << std::string_view{data.data(), data.size()} << std::endl;
});
9. Make a data stream to send messages
auto stream2 = ae::make_unique<ae::P2pStream>(*aether_app->aether()->action_processor, aether2, aether1.uid()))
auto message= std::string_view{"Hello"};
stream2->Write({std::begin(message), std::end(message)});
10. And after all you need to integrate aether_app to yours or build a new event loop
while(!aehter_app->IsExcited()){
auto next_time = aether_app->Update(ae::Now());
aether_app->WaitUntil(next_time);
}
For more full code and more examples see our examples repository
Platformio
C++ Æthernet client library provided as a GitHub repository which Platformio is able to fetch by itself
1. Add an aether-cleint-cpp library dependancy to your platfromio.ini
lib_deps = https://github.com/aethernetio/aether-client-cpp.git
2. Add Æther to your esp idf projects CMakeLists.txt as component
list(APPEND EXTRA_COMPONENT_DIRS "${CMAKE_SOURCE_DIR}/.pio/libdeps/${configName}/Aether/aether")
3. By default Æther is built in production mode but for development purposes we need to set it up in distillation mode. Read about it in Documentation. Add to CMakeLists.txt
set(AE_DISTILLATION On)
4. Require it for your component
idf_component_register(SRCS ${src_list}
INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}
PRIV_REQUIRES aether)
5. Then in your code. Include “aether/aether_app.h” and create an Æthernet application
auto aether_app = ae::AetherApp::Construct({});
6. Register a few clients
constexpr auto parent_uid = ae::Uid::FromString(“<YOUR APPLICATION UID>”);
Client::ptr aether1;
Client::ptr aether2;
ae::BarrierEvent<ae::Client::ptr, 2> clients_registered_event;
aether_app->aether()->RegisterClient(parent_uid)->ResultEvent([&](auto& register){clients_registered_event.Emit<0>(register.client()); });
aether_app->aether()->RegisterClient(parent_uid)->ResultEvent([&](auto& register){clients_registered_event.Emit<1>(register.client()); });
clients_registered_event.Subscribe([&]( auto const& ev){
aether1 = ev.Get<0>();
aether2 = ev.Get<1>();
});
7. Make a data stream to receive messages
auto stream1 = ae::make_unique<ae::P2pStream>(*aether_app->aether()->action_processor, aether1, aether2.uid());
stream1->out_data_event().Subscribe([&](std::vector<std::uint8_t> const& data){
/* ... handle your message … */
std::cout << “Received ” << std::string_view{data.data(), data.size()} << std::endl;
});
8. Make a data stream to send messages
auto stream2 = ae::make_unique<ae::P2pStream>(*aether_app->aether()->action_processor, aether2, aether1.uid()))
auto message= std::string_view{"Hello"};
stream2->Write({std::begin(message), std::end(message)});
9. And after all you need to integrate aether_app to yours or build a new event loop
while(!aehter_app->IsExcited()){
auto next_time = aether_app->Update(ae::Now());
aether_app->WaitUntil(next_time);
}
For more full code and more examples see our examples repository
Arduino
For Arduino a separate repository provided, install it to your Arduino IDE library path
1. Download an Arduino repository as zip file from our repository and install it to arduino ide’s library path. In Arduino Ide select Sketch -> Include Library -> Add .ZIP Library…
2. By default Æther is built in production mode but for development purposes we need to set up it in distillation mode. Read about it in Documentation. Add to build_opt.h
"-D=AE_DISTILLATION=On"
3. Then in your sketch. Include “aether_lib.h” and create an Æthernet application
auto aether_app = ae::AetherApp::Construct({});
4. Register a few clients
constexpr auto parent_uid = ae::Uid::FromString(“<YOUR APPLICATION UID>”);
Client::ptr aether1;
Client::ptr aether2;
ae::BarrierEvent<ae::Client::ptr, 2> clients_registered_event;
aether_app->aether()->RegisterClient(parent_uid)->ResultEvent([&](auto& register){clients_registered_event.Emit<0>(register.client()); });
aether_app->aether()->RegisterClient(parent_uid)->ResultEvent([&](auto& register){clients_registered_event.Emit<1>(register.client()); });
clients_registered_event.Subscribe([&]( auto const& ev){
aether1 = ev.Get<0>();
aether2 = ev.Get<1>();
});
5. Make a data stream to receive messages
auto stream1 = ae::make_unique<ae::P2pStream>(*aether_app->aether()->action_processor, aether1, aether2.uid());
stream1->out_data_event().Subscribe([&](std::vector<std::uint8_t> const& data){
/* ... handle your message … */
std::cout << “Received ” << std::string_view{data.data(), data.size()} << std::endl;
});
6. Make a data stream to send messages
auto stream2 = ae::make_unique<ae::P2pStream>(*aether_app->aether()->action_processor, aether2, aether1.uid()))
auto message= std::string_view{"Hello"};
stream2->Write({std::begin(message), std::end(message)});
7. And after all you need to integrate aether_app to your loop
if(!aehter_app->IsExcited()){
auto next_time = aether_app->Update(ae::Now());
aether_app->WaitUntil(next_time);
}
For more full code and more examples see our examples repository