SkyWay Linux SDK
読み取り中…
検索中…
一致する文字列を見つけられません
context.hpp
1//
2// © NTT DOCOMO BUSINESS, Inc. All Rights Reserved.
3//
4
5#ifndef SKYWAY_CORE_CONTEXT_HPP_
6#define SKYWAY_CORE_CONTEXT_HPP_
7
8#include "skyway/core/config.hpp"
9#include "skyway/core/context_options.hpp"
10#include "skyway/core/interface/remote_member_plugin.hpp"
11#include "skyway/global/error.hpp"
12#include "skyway/global/interface/logger.hpp"
13#include "skyway/network/interface/http_client.hpp"
14#include "skyway/network/interface/websocket_client.hpp"
15#include "skyway/platform/interface/platform_info_delegator.hpp"
16#include "skyway/rtc_api/interface/client.hpp"
17#include "skyway/token/interface/auth_token_manager.hpp"
18
19namespace skyway {
20namespace core {
21namespace channel {
22// forward declaration for testing
23class CoreChannelTest;
24
25} // namespace channel
26namespace ice {
27class CoreIceManagerTest;
28} // namespace ice
29} // namespace core
30
31namespace plugin {
32namespace remote_person {
33namespace connection {
34class RemotePersonPluginReceiverTest;
35class RemotePersonPluginSenderTest;
36} // namespace connection
37} // namespace remote_person
38
39namespace sfu_bot {
40namespace connection {
41class SfuBotPluginConnectionStateObserverTest;
42class SfuBotPluginSenderTest;
43} // namespace connection
44} // namespace sfu_bot
45} // namespace plugin
46
47} // namespace skyway
48
49namespace skyway {
50namespace core {
51
52using RemoteMemberPluginInterface = interface::RemoteMemberPlugin;
53using HttpClientInterface = network::interface::HttpClient;
54using WebSocketClientFactoryInterface = network::interface::WebSocketClientFactory;
55using PlatformInfoDelegatorInterface = platform::interface::PlatformInfoDelegator;
56using LoggerInterface = global::interface::Logger;
57using SkyWayError = global::Error;
58
60class Context {
61public:
63 class EventListener {
64 public:
65 virtual ~EventListener() = default;
66
68 virtual void OnReconnectStart() = 0;
69
71 virtual void OnReconnectSuccess() = 0;
72
76 virtual void OnFatalError(const SkyWayError& error) = 0;
77 };
88 static bool Setup(const std::string& token,
89 std::unique_ptr<HttpClientInterface> http,
90 std::unique_ptr<WebSocketClientFactoryInterface> ws_factory,
91 std::unique_ptr<PlatformInfoDelegatorInterface> platform_info,
92 std::unique_ptr<LoggerInterface> logger,
93 EventListener* listener,
94 const ContextOptions& options);
95
98 static bool UpdateAuthToken(const std::string& token);
99
103 static void _UpdateRtcConfig(ContextOptions::RtcConfig rtc_config);
105
108 static void RegisterPlugin(std::unique_ptr<RemoteMemberPluginInterface> plugin);
109
112 static void Dispose();
113
117 static std::weak_ptr<token::interface::AuthTokenManager> AuthTokenManager();
118
121 static std::weak_ptr<rtc_api::interface::Client> RtcApi();
122
126 static std::weak_ptr<analytics::interface::AnalyticsClient> AnalyticsClient();
127
130 static ContextOptions Options();
131
134 static std::vector<RemoteMemberPluginInterface*> GetRemoteMemberPlugins();
135
140 static RemoteMemberPluginInterface* FindRemoteMemberPluginBySubtype(const std::string& subtype);
141
144 static void OnReconnectStart();
145
148 static void OnReconnectSuccess();
149
153 static void OnFatalError(const SkyWayError& error);
154
158 static std::string GetContextId();
160private:
161 static std::mutex listener_mtx_;
162 static EventListener* listener_;
163 static bool is_setup_;
164 static std::mutex setup_mtx_;
165 static std::shared_ptr<rtc_api::interface::Client> rtc_api_;
166 static std::shared_ptr<token::interface::AuthTokenManager> token_manager_;
167 static std::string context_id_;
168 static std::shared_ptr<analytics::interface::AnalyticsClient> analytics_client_;
169 static ContextOptions options_;
170 static std::vector<std::unique_ptr<RemoteMemberPluginInterface>> plugins_;
171
172public:
174 friend class CoreContextTest;
175 friend class channel::CoreChannelTest;
176 friend class ice::CoreIceManagerTest;
177 friend class plugin::sfu_bot::connection::
178 SfuBotPluginConnectionStateObserverTest; // For analytics client test
179 friend class plugin::sfu_bot::connection::SfuBotPluginSenderTest; // For analytics client test
180 friend class plugin::remote_person::connection::
181 RemotePersonPluginReceiverTest; // For analytics client test
182 friend class plugin::remote_person::connection::RemotePersonPluginSenderTest; // For analytics
183 // client test
185};
186
187} // namespace core
188} // namespace skyway
189
190#endif /* SKYWAY_CORE_CONTEXT_HPP_ */