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} // namespace skyway
31
32namespace skyway {
33namespace core {
34
35using RemoteMemberPluginInterface = interface::RemoteMemberPlugin;
36using HttpClientInterface = network::interface::HttpClient;
37using WebSocketClientFactoryInterface = network::interface::WebSocketClientFactory;
38using PlatformInfoDelegatorInterface = platform::interface::PlatformInfoDelegator;
39using LoggerInterface = global::interface::Logger;
40using SkyWayError = global::Error;
41
43class Context {
44public:
47 public:
48 virtual ~EventListener() = default;
49
51 virtual void OnReconnectStart() = 0;
52
54 virtual void OnReconnectSuccess() = 0;
55
59 virtual void OnFatalError(const SkyWayError& error) = 0;
60 };
71 static bool Setup(const std::string& token,
72 std::unique_ptr<HttpClientInterface> http,
73 std::unique_ptr<WebSocketClientFactoryInterface> ws_factory,
74 std::unique_ptr<PlatformInfoDelegatorInterface> platform_info,
75 std::unique_ptr<LoggerInterface> logger,
76 EventListener* listener,
77 const ContextOptions& options);
78
81 static bool UpdateAuthToken(const std::string& token);
82
86 static void _UpdateRtcConfig(ContextOptions::RtcConfig rtc_config);
88
91 static void RegisterPlugin(std::unique_ptr<RemoteMemberPluginInterface> plugin);
92
95 static void Dispose();
96
100 static std::weak_ptr<token::interface::AuthTokenManager> AuthTokenManager();
101
104 static std::weak_ptr<rtc_api::interface::Client> RtcApi();
105
108 static ContextOptions Options();
109
112 static std::vector<RemoteMemberPluginInterface*> GetRemoteMemberPlugins();
113
118 static RemoteMemberPluginInterface* FindRemoteMemberPluginBySubtype(const std::string& subtype);
119
122 static void OnReconnectStart();
123
126 static void OnReconnectSuccess();
127
131 static void OnFatalError(const SkyWayError& error);
133private:
134 static std::mutex listener_mtx_;
135 static EventListener* listener_;
136 static bool is_setup_;
137 static std::mutex setup_mtx_;
138 static std::shared_ptr<rtc_api::interface::Client> rtc_api_;
139 static std::shared_ptr<token::interface::AuthTokenManager> token_manager_;
140 static ContextOptions options_;
141 static std::vector<std::unique_ptr<RemoteMemberPluginInterface>> plugins_;
142
143public:
145 friend class CoreContextTest;
146 friend class channel::CoreChannelTest;
147 friend class ice::CoreIceManagerTest;
149};
150
151} // namespace core
152} // namespace skyway
153
154#endif /* SKYWAY_CORE_CONTEXT_HPP_ */
イベントリスナ
Definition context.hpp:46
virtual void OnFatalError(const SkyWayError &error)=0
回復不能なエラーが発生した時にコールされます。
virtual void OnReconnectStart()=0
再接続処理が開始した時にコールされます。
virtual void OnReconnectSuccess()=0
再接続が成功した時にコールされます。
SkyWay全体の設定、取得を行うStaticなコンテキスト
Definition context.hpp:43
static void RegisterPlugin(std::unique_ptr< RemoteMemberPluginInterface > plugin)
RemoteMemberPluginを登録します。
static bool Setup(const std::string &token, std::unique_ptr< HttpClientInterface > http, std::unique_ptr< WebSocketClientFactoryInterface > ws_factory, std::unique_ptr< PlatformInfoDelegatorInterface > platform_info, std::unique_ptr< LoggerInterface > logger, EventListener *listener, const ContextOptions &options)
Contextを初期化します。
static bool UpdateAuthToken(const std::string &token)
JWTを更新します。
static void Dispose()
コンテキストを破棄し、全ての接続を切断します。
Definition remote_member_plugin.hpp:16
RTCサーバーへの接続に関する設定
Definition context_options.hpp:47
ContextのSetup時に使用するオプション
Definition context_options.hpp:22
SkyWayで発生したエラーを示す構造体
Definition error.hpp:14