aboutsummaryrefslogtreecommitdiffstats
path: root/sample/README.md
diff options
context:
space:
mode:
authorAndrey Shamanin <andrei.shamanin@orioninc.com>2020-10-16 16:08:27 +0300
committerAndrey Shamanin <andrei.shamanin@orioninc.com>2020-10-19 15:41:37 +0300
commit2d66933b9bf25af66696b097283109c8a6e87151 (patch)
tree92a0bc61822540d5175a87d643fcca24d4acb216 /sample/README.md
parentaee2ff16cc87a939e68aa2900e23d6705dda5408 (diff)
Bug-AGL: SPEC-3645 Signed-off-by: Andrey Shamanin <andrei.shamanin@orioninc.com> Change-Id: Ie165a50e7975a8e6f25b259be1679a9689414148
Diffstat (limited to 'sample/README.md')
-rwxr-xr-xsample/README.md66
1 files changed, 42 insertions, 24 deletions
diff --git a/sample/README.md b/sample/README.md
index 8edaddd..dd05521 100755
--- a/sample/README.md
+++ b/sample/README.md
@@ -36,7 +36,7 @@ CloudProxy client hides the communication with CloudProxy server. It incupsulate
* Include the appropriate header to appliciation
```
- #include "cloudproxy-client/cloudproxyclient.h"
+ #include "libcloudproxy.h"
```
* Initialization of the CloudProxy client inside the application:
@@ -57,36 +57,53 @@ g_cloudproxyclient->init(port, token.c_str());
```
-g_cloudproxyclient->set_event_handler(CloudProxyClient::Event_SendMessageConfirmation, [](json_object* object){
- json_object *j_result;
- if(!json_object_object_get_ex(object, "result", &j_result))
- {
- qDebug("Can't read confirmation result");
- return;
- }
-
- qDebug("Confirmation result %d", (int)json_object_get_boolean(j_result));
- });
+ g_cloudproxyclient->set_event_handler(CloudProxyClient::Event_SendMessageConfirmation, [](json_object* object){
+ json_object *j_obj;
+ const char* cloud_type{nullptr};
+ if(!json_object_object_get_ex(object, "cloud_type", &j_obj) ||
+ (cloud_type = json_object_get_string(j_obj)) == nullptr)
+ {
+ qDebug("Can't read cloud_type");
+ return;
+ }
+
+ if(!json_object_object_get_ex(object, "result", &j_obj))
+ {
+ qDebug("Can't read confirmation result");
+ return;
+ }
+
+ qDebug("Confirmation result from %s: %d", cloud_type, (int)json_object_get_boolean(j_obj));
+ });
```
-* Subsription to the Event_SendMessageConfirmation
+* Subsription to the Event_ReceivedMessage
```
g_cloudproxyclient->set_event_handler(CloudProxyClient::Event_ReceivedMessage, [](json_object* object)
- json_object *event_data;
- const char* data_str{nullptr};
- if(!json_object_object_get_ex(object, "data", &event_data) ||
- data_str = json_object_get_string(event_data)) == nullptr)
- {
- qDebug("Can't read event data");
- return;
- }
-
- qDebug("Received data: %s", data_str);
- });
+ json_object *j_obj;
+ const char* cloud_type{nullptr};
+ if(!json_object_object_get_ex(object, "cloud_type", &j_obj) ||
+ (cloud_type = json_object_get_string(j_obj)) == nullptr)
+ {
+ qDebug("Can't read cloud_type");
+ return;
+ }
+
+ json_object *event_data;
+ const char* data_str{nullptr};
+ if(!json_object_object_get_ex(object, "data", &event_data) ||
+ (data_str = json_object_get_string(event_data)) == nullptr)
+ {
+ qDebug("Can't read event data");
+ return;
+ }
+
+ qDebug("Received data from %s: %s", cloud_type, data_str);
+ });
```
@@ -94,5 +111,6 @@ g_cloudproxyclient->set_event_handler(CloudProxyClient::Event_ReceivedMessage, [
```
-qDebug() << "sendMessage result: " << g_cloudproxyclient->sendMessage("{\"app_key\": \"app_value1111\"}");
+qDebug() << "sendMessage to Azure: result: " << g_cloudproxyclient->sendMessage(CloudType::Azure, "{\"app_key\": \"app_value1111\"}");
+qDebug() << "sendMessage to AWS: result: " << g_cloudproxyclient->sendMessage(CloudType::Aws, "{\"app_key\": \"app_value1111\"}");
``` \ No newline at end of file