OpenFin C++ Adapter 1.1.0

Loading...
Searching...
No Matches
OpenFinAdapter.h
1#pragma once
2
3#include <future>
4#include <string>
5#include <map>
6
7// common.h
8#define OPENFIN_ADAPTER_API __declspec(dllimport)
9
10namespace OpenFinAdapterApi {
11 using namespace std;
12 // EndpointId.h
15 {
16 public:
17 std::string uuid;
18 std::string name;
19 std::string channelName;
20 std::string channelId;
21 std::string endpointId;
22 };
23
24 // MessageChannelClient.h
26 class OPENFIN_ADAPTER_API MessageChannelClient
27 {
28 public:
32 void registerTopic(const string& topic, const function<shared_ptr<string>(shared_ptr<string>, EndpointId)>& listener);
33
36 void unregisterTopic(const string& topic);
37 };
38
39 // ChannelClient.h
41 class OPENFIN_ADAPTER_API ChannelClient : public MessageChannelClient
42 {
43 public:
47 shared_future<void> connectAsync(bool wait = true);
48
51 shared_future<void> disconnectAsync() const;
52
56 shared_future<shared_ptr<string>> dispatchAsync(const string& topic) const;
57
62 shared_future<shared_ptr<string>> dispatchAsync(const string& topic, const string& payloadJson) const;
63
66 void subscribeDisconnected(const function<void()>& listener);
67
70 void unsubscribeDisconnected(const function<void()>& listener);
71 };
72
73 // ChannelProvider.h
75 class OPENFIN_ADAPTER_API ChannelProvider : public MessageChannelClient
76 {
77 public:
80 shared_future<void> openAsync();
81
84 void subscribeClientConnected(const function<void(const EndpointId&)>& listener);
85
88 void unsubscribeClientConnected(const function<void(const EndpointId&)>& listener);
89
92 void subscribeClientDisconnected(const function<void(const EndpointId&)>& listener);
93
96 void unsubscribeClientDisconnected(const function<void(const EndpointId&)>& listener);
97
102 shared_future<shared_ptr<string>> dispatchAsync(const EndpointId& targetChannel, const string& topic) const;
103
109 shared_future<shared_ptr<string>> dispatchAsync(const EndpointId& targetChannel, const string& topic, const string& payloadJson) const;
110
115 shared_future<shared_ptr<string>> broadcastAsync(const string& topic, const string& payloadJson) const;
116
120 shared_future<shared_ptr<string>> broadcastAsync(const string& topic) const;
121 };
122
123 // Channels.h
125 class OPENFIN_ADAPTER_API Channels
126 {
127 public:
131 shared_ptr<ChannelClient> createClient(const string& channelName);
132
136 shared_ptr<ChannelProvider> createProvider(const string& channelName);
137 };
138
139 // OpenFinApiException.h
141 class OPENFIN_ADAPTER_API OpenFinApiException : public std::exception
142 {
143 public:
144 OpenFinApiException(const std::string& message);
145
146 const char* what() const noexcept override;
147 };
148
149 // RvmOptions.h
151 class OPENFIN_ADAPTER_API RvmOptions
152 {
153
154 public:
155 struct RvmCacheKey {
156 string productName;
157 string productVersion;
158 string companyName;
159 string runtimeVersion;
160 };
161
162 bool noUi;
163 bool disableAutoUpdates;
164 bool doNotLaunch;
165 string installDirectory;
166 string workingDirectory;
167 RvmCacheKey cacheKey;
168
169 RvmOptions(bool no_ui,
170 bool disableAutoUpdates,
171 bool doNotLaunch,
172 const string& installDirectory,
173 const string& workingDirectory,
174 const string& productName,
175 const string& productVersion,
176 const string& companyName,
177 const string& runtimeVersion);
178 };
179
180 // RuntimeOptions.h
182 class OPENFIN_ADAPTER_API RuntimeOptions
183 {
184 public:
190 WindowClass
191 };
192
194 enum class RuntimeConnectOptions : uint16_t {
196 None = 0x0000,
198 NonPersistent = 0x0001,
199 };
200
202 string uuid;
203
206
208 string version;
209
211 string host;
212
214 int32_t port;
215
218
220 string arguments;
221
224
227
230
242 RuntimeOptions(const string& uuid,
243 const string& licenseKey,
244 const string& version,
245 const string& host,
246 int32_t port,
247 PortDiscoveryMode portDiscoveryMode,
248 const string& arguments,
249 const RvmOptions& rvmOptions,
250 const string& securityRealm,
251 const RuntimeConnectOptions runtimeConnectOptions = RuntimeConnectOptions::None);
252
258 const string& uuid,
259 const string& licenseKey,
260 const string& version
261 );
262
263 };
264
265 // DesktopSystem.h
268 class OPENFIN_ADAPTER_API DesktopSystem {
269 public:
270 shared_future<shared_ptr<string>> launchManifest(const string& manifestUrl, const shared_ptr<RvmOptions>& rvmOptions = nullptr) const;
271 };
272
273 // Runtime.h
276 class OPENFIN_ADAPTER_API Runtime
277 {
278 public:
281 bool isConnected() const;
282
284 string getRuntimeId();
285
288
291 future<void> connectAsync();
292
295 future<void> disconnectAsync();
296
299 shared_ptr<Channels> getChannels();
300
303 shared_ptr<DesktopSystem> getDesktopSystem();
304
307 void subscribeDisconnected(const function<void()>& listener);
308
311 void unsubscribeDisconnected(const function<void()>& listener);
312 };
313
314 // RuntimeFactory.h
316 class OPENFIN_ADAPTER_API RuntimeFactory
317 {
318 private:
319 map<string, shared_ptr<Runtime>> runtimes;
320
321 public:
325 shared_ptr<Runtime> getRuntimeInstance(const RuntimeOptions& runtimeOptions);
326 };
327}
Represents a Channel Client that can connect to a Channel Provider.
Definition OpenFinAdapter.h:42
shared_future< void > connectAsync(bool wait=true)
Connects the client to a channel.
void unsubscribeDisconnected(const function< void()> &listener)
Un-registers a listener from the channel disconnected event.
shared_future< shared_ptr< string > > dispatchAsync(const string &topic, const string &payloadJson) const
Dispatches a payload on a topic to the channel provider.
void subscribeDisconnected(const function< void()> &listener)
Creates a subscription to the channel disconnected event.
shared_future< shared_ptr< string > > dispatchAsync(const string &topic) const
Dispatches a signal on a topic to a channel provider, with no payload.
shared_future< void > disconnectAsync() const
Disconnects the client from the channel.
Represents a Channel Provider that accepts connections from Channel Clients.
Definition OpenFinAdapter.h:76
void unsubscribeClientConnected(const function< void(const EndpointId &)> &listener)
Un-registers a listener from being called upon client connections.
void subscribeClientDisconnected(const function< void(const EndpointId &)> &listener)
Registers a listener function that will be called upon client disconnections.
shared_future< shared_ptr< string > > dispatchAsync(const EndpointId &targetChannel, const string &topic) const
Dispatches an empty message to a remote endpoint on a topic.
shared_future< shared_ptr< string > > broadcastAsync(const string &topic) const
Dispatches an empty message to all connected clients on a topic.
void unsubscribeClientDisconnected(const function< void(const EndpointId &)> &listener)
Un-registers a listener from being called upon client disconnections.
void subscribeClientConnected(const function< void(const EndpointId &)> &listener)
Registers a listener function that will be called upon client connections.
shared_future< shared_ptr< string > > dispatchAsync(const EndpointId &targetChannel, const string &topic, const string &payloadJson) const
Dispatches a payload to a remote endpoint on a topic.
shared_future< void > openAsync()
Opens the Channel Provider, making it available for client connections.
shared_future< shared_ptr< string > > broadcastAsync(const string &topic, const string &payloadJson) const
Dispatches a payload to all connected clients.
Represents Channels connectivity for a Runtime connection, providing functions for creating clients a...
Definition OpenFinAdapter.h:126
shared_ptr< ChannelClient > createClient(const string &channelName)
Creates a Channel Client for the given channel name.
shared_ptr< ChannelProvider > createProvider(const string &channelName)
Creates a Channel Provider with the given name.
The Desktop System API.
Definition OpenFinAdapter.h:268
Base class for a channel client and channel provider.
Definition OpenFinAdapter.h:27
void registerTopic(const string &topic, const function< shared_ptr< string >(shared_ptr< string >, EndpointId)> &listener)
Registers a listener of a topic.
void unregisterTopic(const string &topic)
Unregisters a listener of a topic.
Represents and error thrown by the OpenFin runtime API.
Definition OpenFinAdapter.h:142
A factory for creating runtime instances from a set of runtime options.
Definition OpenFinAdapter.h:317
shared_ptr< Runtime > getRuntimeInstance(const RuntimeOptions &runtimeOptions)
Gets a runtime instance for the given options.
The options required for initialising the runtime.
Definition OpenFinAdapter.h:183
RuntimeConnectOptions runtimeConnectOptions
Advanced settings to configure how the adapter manages and connects to a runtime instance.
Definition OpenFinAdapter.h:229
string version
Requested Runtime Version to connect to.
Definition OpenFinAdapter.h:208
string securityRealm
Security Realm.
Definition OpenFinAdapter.h:226
RuntimeConnectOptions
Advanced settings to configure how the adapter manages and connects to a runtime instance.
Definition OpenFinAdapter.h:194
PortDiscoveryMode
Enum of the port discovery mode to use.
Definition OpenFinAdapter.h:186
@ None
No port discovery. The provided port will be used.
Definition OpenFinAdapter.h:188
string host
Requested Runtime defaults to 127.0.0.1.
Definition OpenFinAdapter.h:211
string license_key
The per-customer or per-contract licensing identifier for the RVM.
Definition OpenFinAdapter.h:205
RvmOptions * rvmOptions
The RVM Options to be used.
Definition OpenFinAdapter.h:223
RuntimeOptions(const string &uuid, const string &licenseKey, const string &version)
Constructs a new instance of the RuntimeOptions.
RuntimeOptions(const string &uuid, const string &licenseKey, const string &version, const string &host, int32_t port, PortDiscoveryMode portDiscoveryMode, const string &arguments, const RvmOptions &rvmOptions, const string &securityRealm, const RuntimeConnectOptions runtimeConnectOptions=RuntimeConnectOptions::None)
Constructs a new instance of the RuntimeOptions.
int32_t port
Requested Runtime port number; only used when PortDiscovery is disabled.
Definition OpenFinAdapter.h:214
string arguments
Arguments to be passed to the Runtime.
Definition OpenFinAdapter.h:220
PortDiscoveryMode portDiscoveryMode
Determines Port discovery methods to be used. Defaults to all available.
Definition OpenFinAdapter.h:217
string uuid
Connection UUID.
Definition OpenFinAdapter.h:202
Represents a connection to the OpenFin runtime.
Definition OpenFinAdapter.h:277
string getRuntimeId()
Gets the runtime ID.
future< void > disconnectAsync()
Disconnects from the runtime.
shared_ptr< Channels > getChannels()
Gets the Channels object.
future< void > connectAsync()
Initialises and connects to the runtime.
RuntimeOptions getRuntimeOptions()
Gets the Runtime options.
void subscribeDisconnected(const function< void()> &listener)
Registers a listener function that will be called when the adapter disconnects.
bool isConnected() const
Gets whether the runtime is connected.
shared_ptr< DesktopSystem > getDesktopSystem()
Gets the Desktop System API object.
void unsubscribeDisconnected(const function< void()> &listener)
Unregisters a listener function such that it will no longer be called when the adapter disconnects.
The options required to initialise the RVM.
Definition OpenFinAdapter.h:152
A structure that identifies a Channels endpoint.
Definition OpenFinAdapter.h:15
Definition OpenFinAdapter.h:155