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