OpenFin C++ Adapter 1.0.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 string uuid;
195
198
200 string version;
201
203 string host;
204
206 int32_t port;
207
210
212 string arguments;
213
216
219
230 RuntimeOptions(const string& uuid,
231 const string& licenseKey,
232 const string& version,
233 const string& host,
234 int32_t port,
235 PortDiscoveryMode portDiscoveryMode,
236 const string& arguments,
237 const RvmOptions& rvmOptions,
238 const string& securityRealm);
239
245 const string& uuid,
246 const string& licenseKey,
247 const string& version
248 );
249
250 };
251
252 // DesktopSystem.h
255 class OPENFIN_ADAPTER_API DesktopSystem {
256 public:
257 shared_future<shared_ptr<string>> launchManifest(const string& manifestUrl, const shared_ptr<RvmOptions>& rvmOptions = nullptr) const;
258 };
259
260 // Runtime.h
263 class OPENFIN_ADAPTER_API Runtime
264 {
265 public:
268 bool isConnected() const;
269
271 string getRuntimeId();
272
275
278 future<void> connectAsync();
279
282 future<void> disconnectAsync();
283
286 shared_ptr<Channels> getChannels();
287
290 shared_ptr<DesktopSystem> getDesktopSystem();
291
294 void subscribeDisconnected(const function<void()>& listener);
295
298 void unsubscribeDisconnected(const function<void()>& listener);
299 };
300
301 // RuntimeFactory.h
303 class OPENFIN_ADAPTER_API RuntimeFactory
304 {
305 private:
306 map<string, shared_ptr<Runtime>> runtimes;
307
308 public:
312 shared_ptr<Runtime> getRuntimeInstance(const RuntimeOptions& runtimeOptions);
313 };
314}
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:255
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:304
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
string version
Requested Runtime Version to connect to.
Definition OpenFinAdapter.h:200
string securityRealm
Security Realm.
Definition OpenFinAdapter.h:218
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:203
string license_key
The per-customer or per-contract licensing identifier for the RVM.
Definition OpenFinAdapter.h:197
RvmOptions * rvmOptions
The RVM Options to be used.
Definition OpenFinAdapter.h:215
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)
Constructs a new instance of the RuntimeOptions.
int32_t port
Requested Runtime port number; only used when PortDiscovery is disabled.
Definition OpenFinAdapter.h:206
string arguments
Arguments to be passed to the Runtime.
Definition OpenFinAdapter.h:212
PortDiscoveryMode portDiscoveryMode
Determines Port discovery methods to be used. Defaults to all available.
Definition OpenFinAdapter.h:209
string uuid
Connection UUID.
Definition OpenFinAdapter.h:194
Represents a connection to the OpenFin runtime.
Definition OpenFinAdapter.h:264
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