This repository has been archived by the owner on Jan 3, 2023. It is now read-only.
forked from open-amt-cloud-toolkit/rpc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
heartbeat.cpp
48 lines (37 loc) · 1.5 KB
/
heartbeat.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*********************************************************************
* Copyright (c) Intel Corporation 2019 - 2020
* SPDX-License-Identifier: Apache-2.0
**********************************************************************/
#include "heartbeat.h"
#include <cpprest/ws_client.h>
#include <cpprest/json.h>
#include <cpprest/streams.h>
#include <iostream>
#include <string>
#include "activation.h"
#include "version.h"
#include "commands.h"
#include "network.h"
#include "utils.h"
bool heartbeat_create_response(std::string& response)
{
web::json::value msg;
utility::string_t tmp = utility::conversions::convertstring("heartbeat_response");
msg[U("method")] = web::json::value::string(tmp);
tmp = utility::conversions::convertstring("");
msg[U("apiKey")] = web::json::value::string(tmp);
tmp = utility::conversions::convertstring(PROJECT_VER);
msg[U("appVersion")] = web::json::value::string(tmp);
tmp = utility::conversions::convertstring(PROTOCOL_VERSION);
msg[U("protocolVersion")] = web::json::value::string(tmp);
tmp = utility::conversions::convertstring("success");
msg[U("status")] = web::json::value::string(tmp);
tmp = utility::conversions::convertstring("");
msg[U("message")] = web::json::value::string(tmp);
// set empty payload
tmp = utility::conversions::convertstring("");
msg[U("payload")] = web::json::value::string(tmp);
// serialize the entire message
response = utility::conversions::to_utf8string(msg.serialize());
return true;
}