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);
36
37 ChunkMessengerInterface* Messenger() const override;
39 std::shared_ptr<interface::Publication> Publish(
40 std::shared_ptr<LocalStream> stream,
42 std::shared_ptr<interface::Subscription> Subscribe(
43 const std::string& publication_id,
44 const interface::LocalPerson::SubscriptionOptions& options) override;
45 bool Unpublish(const std::string& publication_id) const override;
46 bool Unsubscribe(const std::string& subscription_id) const override;
48 void OnPublished(std::shared_ptr<interface::Publication> publication) override;
49 void OnUnpublished(std::shared_ptr<interface::Publication> publication) override;
50 void OnSubscribed(std::shared_ptr<interface::Subscription> subscription,
51 std::shared_ptr<interface::RemoteMember> publisher) override;
52 void OnUnsubscribed(std::shared_ptr<interface::Subscription> subscription,
53 std::shared_ptr<interface::RemoteMember> publisher) override;
54 void OnPublicationSubscribedByRemoteMember(
55 std::shared_ptr<interface::Subscription> subscription,
56 std::shared_ptr<interface::RemoteMember> subscriber) override;
57 void OnPublicationUnsubscribedByRemoteMember(
58 std::shared_ptr<interface::Subscription> subscription,
59 std::shared_ptr<interface::RemoteMember> subscriber) override;
60 void Dispose() override;
62
63 // AnalyticsClientInterface::Delegator
64 std::vector<analytics::interface::AnalyticsClient::SubscriptionStats>
65 GetSubscriptionStatsForAnalytics() const override;
66
67private:
68 void UpdateMemberTtl(const std::string& channel_id, int keepalive_interval_sec);
69 void SetupTtlTimer();
70 using SubscriptionId = std::string;
71 using SubscriptionPair = std::pair<std::weak_ptr<interface::Subscription>,
73
74 std::unique_ptr<ChunkMessengerInterface> messenger_;
75 std::mutex tmp_subscriptions_mtx_;
76 std::unordered_map<SubscriptionId, SubscriptionPair> tmp_subscriptions_;
77 int keepalive_interval_sec_;
78 int keepalive_interval_gap_sec_;
79
80 std::mutex stream_mtx_;
81
82 std::mutex is_disposed_mtx_;
83 std::condition_variable is_disposed_cv_;
84 bool is_disposed_;
85 std::unique_ptr<std::thread> ttl_timer_thread_;
86};
87
88} // namespace member
89} // namespace channel
90} // namespace core
91} // namespace skyway
92
93#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:37
SubscribeでSubscriptionに対して指定するオプション
Definition local_person.hpp:53
メンバー情報
Definition domain.hpp:53