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