SkyWay Linux SDK
読み取り中…
検索中…
一致する文字列を見つけられません
data_stream.hpp
1//
2// data_stream.hpp
3// skyway
4//
5// Created by sandabu on 2022/01/28.
6// Copyright © 2022 NTT Communications. All rights reserved.
7//
8
9#ifndef SKYWAY_CORE_STREAM_LOCAL_DATA_STREAM_HPP_
10#define SKYWAY_CORE_STREAM_LOCAL_DATA_STREAM_HPP_
11
12#include <atomic>
13#include <mutex>
14
15#include "skyway/core/interface/local_stream.hpp"
16
17namespace skyway {
18namespace core {
19namespace stream {
20namespace local {
21
22using LocalStream = interface::LocalStream;
23
26public:
27 using PublicationId = std::string;
29 struct SendingData {
30 bool is_binary;
31 std::vector<uint8_t> data;
32 };
33 class InternalListener {
34 public:
35 virtual bool OnWriteData(const SendingData& buffer,
36 const PublicationId& publication_id) = 0;
37 };
41 void AddInternalListener(const std::string& remote_member_id,
42 const PublicationId& publication_id,
43 InternalListener* listener);
44 void RemoveInternalListener(const std::string& remote_member_id,
45 const PublicationId& publication_id);
48 bool Write(const std::string& data) const;
50 bool Write(const uint8_t* data, size_t length) const;
51
54 bool Enable() override;
56 bool Disable() override;
58
59private:
60 std::unordered_map<std::string, std::unordered_map<PublicationId, InternalListener*>>
61 listeners_;
62 mutable std::mutex listener_mtx_;
63 std::atomic<bool> is_enabled_;
64};
65
66} // namespace local
67} // namespace stream
68} // namespace core
69} // namespace skyway
70
71#endif /* SKYWAY_CORE_STREAM_LOCAL_DATA_STREAM_HPP_ */
LocalPersonで扱うStream
Definition local_stream.hpp:21
LocalPersonで扱うDataStream
Definition data_stream.hpp:25
bool Write(const std::string &data) const
文字列を送信します。
bool Write(const uint8_t *data, size_t length) const
バイト列を送信します。