-
Notifications
You must be signed in to change notification settings - Fork 87
Expand file tree
/
Copy pathClient.h
More file actions
79 lines (66 loc) · 2.65 KB
/
Client.h
File metadata and controls
79 lines (66 loc) · 2.65 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Copyright (C) Microsoft Corporation.
// Copyright (C) 2025 IAMAI CONSULTING CORP
//
// MIT License. All rights reserved.
#pragma once
#include <AirSimMessage/request_message.hpp>
#include <functional>
#include <memory>
#include <string>
#include <vector>
#include "ASCDecl.h"
#include "AsyncResult.h"
#include "Message.h"
#include "Status.h"
namespace microsoft {
namespace projectairsim {
namespace client {
// Client connection to Project AirSim server
class Client {
public:
// Topic callback function prototype
typedef std::function<void(const std::string& str_topic_name,
const std::string& str_message)>
TopicCallback;
public:
static constexpr unsigned int kPortTopicsDefault = 8989;
static constexpr unsigned int kPortServicesDefault = 8990;
public:
ASC_DECL Client(void) noexcept;
ASC_DECL ~Client();
// Version methods
ASC_DECL static const char* GetNNGVersion(void);
ASC_DECL static const char* GetVersion(void);
// Connection methods
ASC_DECL Status Connect(const std::string& address,
unsigned int port_topics = kPortTopicsDefault,
unsigned int port_services = kPortServicesDefault);
ASC_DECL void Disconnect(void) noexcept;
// Topic methods
ASC_DECL std::vector<std::string> GetTopicInfo(void);
ASC_DECL Status Subscribe(const char* sz_topic_name,
TopicCallback topic_callback);
ASC_DECL Status Unsubscribe(const char* sz_topic_name);
ASC_DECL Status Unsubscribe(const std::vector<std::string>& vec_topic_name);
ASC_DECL Status UnsubscribeAll(void) noexcept;
// Service methods
ASC_DECL void CancelAllRequests(void) noexcept;
ASC_DECL Status Request(const std::string& str_method,
const nlohmann::json& json_parameters,
client::Message* pmessage_response_out) noexcept;
ASC_DECL TAsyncResult<Message> RequestAsync(
const std::string& str_method, const nlohmann::json& json_parameters,
FnResponseCallback fnresponsecallback = nullptr) noexcept;
ASC_DECL Status RequestLoadScene(const std::string& str_scene_config,
client::Message* pmessage_response_out);
ASC_DECL TAsyncResult<Message> RequestPriorityAsync(
const std::string& str_method, const nlohmann::json& json_parameters,
FnResponseCallback fnresponse_callback) noexcept;
protected:
class Impl; // Client implementation
protected:
std::unique_ptr<Impl> pclient_impl_; // Pointer to implementation instance
}; // class Client
} // namespace client
} // namespace projectairsim
} // namespace microsoft