SkyWay Linux SDK
読み取り中…
検索中…
一致する文字列を見つけられません
local_person.hpp
1//
2// © NTT DOCOMO BUSINESS, Inc. All Rights Reserved.
3//
4
5#ifndef SKYWAY_CORE_CHANNEL_MEMBER_LOCAL_PERSON_HPP_
6#define SKYWAY_CORE_CHANNEL_MEMBER_LOCAL_PERSON_HPP_
7
8#include <api/peer_connection_interface.h>
9
10#include <string>
11#include <unordered_map>
12
13#include "skyway/analytics/interface/analytics_client.hpp"
14#include "skyway/core/interface/local_person.hpp"
15#include "skyway/signaling/interface/signaling_client.hpp"
16
17namespace skyway {
18namespace core {
19namespace channel {
20namespace member {
21
22using LocalStream = interface::LocalStream;
23using ChunkMessengerInterface = interface::ChunkMessenger;
24using AnalyticsClientInterface = analytics::interface::AnalyticsClient;
25
27class LocalPerson : public interface::LocalPerson, public AnalyticsClientInterface::Delegator {
28public:
30 LocalPerson(std::shared_ptr<interface::Channel> channel,
31 const model::Member& dto,
32 std::unique_ptr<ChunkMessengerInterface> messenger,
33 int keepalive_interval_sec,
34 int keepalive_interval_gap_sec,
35 std::unique_ptr<AnalyticsClientInterface> analytics_client);
37
38 ChunkMessengerInterface* Messenger() const override;
39
40 AnalyticsClientInterface* AnalyticsClient() const override;
42
43 std::shared_ptr<interface::Publication> Publish(std::shared_ptr<LocalStream> stream,
45 std::shared_ptr<interface::Subscription> Subscribe(
46 const std::string& publication_id,
47 const interface::LocalPerson::SubscriptionOptions& options) override;
48 bool Unpublish(const std::string& publication_id) const override;
49 bool Unsubscribe(const std::string& subscription_id) const override;
51 void OnPublished(std::shared_ptr<interface::Publication> publication) override;
52 void OnUnpublished(std::shared_ptr<interface::Publication> publication) override;
53 void OnSubscribed(std::shared_ptr<interface::Subscription> subscription, std::shared_ptr<interface::RemoteMember> publisher) override;
54 void OnUnsubscribed(std::shared_ptr<interface::Subscription> subscription, std::shared_ptr<interface::RemoteMember> publisher) override;
55 void OnPublicationSubscribedByRemoteMember(std::shared_ptr<interface::Subscription> subscription,
56 std::shared_ptr<interface::RemoteMember> subscriber) override;
57 void OnPublicationUnsubscribedByRemoteMember(std::shared_ptr<interface::Subscription> subscription,
58 std::shared_ptr<interface::RemoteMember> subscriber) override;
59 void Dispose() override;
61
62 // AnalyticsClientInterface::Delegator
63 std::vector<analytics::interface::AnalyticsClient::SubscriptionStats> GetSubscriptionStatsForAnalytics()
64 const override;
65
66private:
67 void UpdateMemberTtl(const std::string& channel_id, int keepalive_interval_sec);
68 void SetupTtlTimer();
69 using SubscriptionId = std::string;
70 using SubscriptionPair =
71 std::pair<std::weak_ptr<interface::Subscription>, interface::LocalPerson::SubscriptionOptions>;
72
73 std::unique_ptr<ChunkMessengerInterface> messenger_;
74 std::mutex tmp_subscriptions_mtx_;
75 std::unordered_map<SubscriptionId, SubscriptionPair> tmp_subscriptions_;
76 int keepalive_interval_sec_;
77 int keepalive_interval_gap_sec_;
78
79 std::unique_ptr<AnalyticsClientInterface> analytics_client_;
80
81 std::mutex stream_mtx_;
82
83 std::mutex is_disposed_mtx_;
84 std::condition_variable is_disposed_cv_;
85 bool is_disposed_;
86 std::unique_ptr<std::thread> ttl_timer_thread_;
87};
88
89} // namespace member
90} // namespace channel
91} // namespace core
92} // namespace skyway
93
94#endif /* SKYWAY_CORE_CHANNEL_MEMBER_LOCAL_PERSON_HPP_ */
LocalPersonの実装クラス
Definition local_person.hpp:27
std::shared_ptr< interface::Publication > Publish(std::shared_ptr< LocalStream > stream, interface::LocalPerson::PublicationOptions options) override
Streamを公開します。
bool Unpublish(const std::string &publication_id) const override
公開しているPublicationを非公開にします。
std::shared_ptr< interface::Subscription > Subscribe(const std::string &publication_id, const interface::LocalPerson::SubscriptionOptions &options) override
公開されているPublicationを購読します。
bool Unsubscribe(const std::string &subscription_id) const override
購読しているSubscriptionの購読を解除します。
LocalPersonのインターフェース
Definition local_person.hpp:19
PublishでPublicationに対して指定するオプション
Definition local_person.hpp:35
SubscribeでSubscriptionに対して指定するオプション
Definition local_person.hpp:50
メンバー情報
Definition domain.hpp:53