Agora RTC Objective-C API Reference Refactor

NGIAgoraDataChannel.h
Go to the documentation of this file.
1
2 // Copyright (c) 2022 Agora.io. All rights reserved
3
4 // This program is confidential and proprietary to Agora.io.
5 // And may not be copied, reproduced, modified, disclosed to others, published
6 // or used, in whole or in part, without the express prior written permission
7 // of Agora.io.
8 #pragma once // NOLINT(build/header_guard)
9
10 #include "AgoraRefPtr.h"
11 #include "AgoraBase.h"
12 namespace agora {
13
17 struct DataChannelConfig {
23 bool syncWithMedia;
29 bool ordered;
30
36 int compressionLength;
37 // optional
38 Optional<int> channelId; // 0~7
39 DataChannelConfig() :
40 syncWithMedia(false),
41 ordered(false),
42 compressionLength(0) {}
43 };
44
48 struct DataChannelInfo {
52 int dataChannelId;
56 util::AString metadata;
57 };
58
62 struct UserDataChannelInfo {
66 util::AString userId;
70 const DataChannelInfo* infos;
74 size_t info_size;
75 };
76
77 class ILocalDataChannel : public RefCountInterface {
78 public:
88 virtual int sendDataPacket(const char* packet, size_t length) = 0;
98 virtual int setMetaData(const char* metaData, size_t length) = 0;
99
105 virtual Optional<int> configuredChannelId() const = 0;
106
107 protected:
108 virtual ~ILocalDataChannel() {}
109 };
110
111 class IRemoteDataChannel: public RefCountInterface {
112 public:
113 virtual util::AString UserId() const = 0;
114 virtual int ChannelId() const = 0;
115 virtual util::AString Meta() = 0;
116
117 protected:
118 virtual ~IRemoteDataChannel() {}
119 };
120
121 class IDataChannelObserver {
122 public:
127 virtual void onLocalDataChannelPublished(agora_refptr<ILocalDataChannel> channel) {}
128
133 virtual void onRemoteDataChannelSubscribed(agora_refptr<IRemoteDataChannel> channel) {}
134
139 virtual void onRemoteDataChannelUnsubscribed(agora_refptr<IRemoteDataChannel> channel) {}
145 virtual void onRemoteDataPacketReceived(const UserDataChannelInfo& info, util::AString packet) {}
146
154 virtual void onRemoteDataChannelInfoUpdated(const UserDataChannelInfo* modified_infos, size_t modified_infos_size,
155 const UserDataChannelInfo* deleted_infos, size_t deleted_infos_size) {}
156 virtual ~IDataChannelObserver() {}
157 };
158
159 } // namespace agora
agora::IRemoteDataChannel::~IRemoteDataChannel
virtual ~IRemoteDataChannel()
Definition: NGIAgoraDataChannel.h:118
agora::DataChannelConfig::syncWithMedia
bool syncWithMedia
Definition: NGIAgoraDataChannel.h:23
AgoraBase.h
agora::agora_refptr
Definition: AgoraRefPtr.h:44
agora::ILocalDataChannel::sendDataPacket
virtual int sendDataPacket(const char *packet, size_t length)=0
agora::IDataChannelObserver::onRemoteDataPacketReceived
virtual void onRemoteDataPacketReceived(const UserDataChannelInfo &info, util::AString packet)
Definition: NGIAgoraDataChannel.h:145
agora::UserDataChannelInfo::userId
util::AString userId
Definition: NGIAgoraDataChannel.h:66
agora::IRemoteDataChannel::Meta
virtual util::AString Meta()=0
agora::IDataChannelObserver::~IDataChannelObserver
virtual ~IDataChannelObserver()
Definition: NGIAgoraDataChannel.h:156
agora::IDataChannelObserver::onRemoteDataChannelInfoUpdated
virtual void onRemoteDataChannelInfoUpdated(const UserDataChannelInfo *modified_infos, size_t modified_infos_size, const UserDataChannelInfo *deleted_infos, size_t deleted_infos_size)
Definition: NGIAgoraDataChannel.h:154
agora::DataChannelConfig::DataChannelConfig
DataChannelConfig()
Definition: NGIAgoraDataChannel.h:39
agora::IRemoteDataChannel
Definition: NGIAgoraDataChannel.h:111
agora::IDataChannelObserver::onRemoteDataChannelSubscribed
virtual void onRemoteDataChannelSubscribed(agora_refptr< IRemoteDataChannel > channel)
Definition: NGIAgoraDataChannel.h:133
agora::ILocalDataChannel::setMetaData
virtual int setMetaData(const char *metaData, size_t length)=0
agora::DataChannelConfig::ordered
bool ordered
Definition: NGIAgoraDataChannel.h:29
agora
Definition: AgoraAtomicOps.h:21
agora::UserDataChannelInfo::infos
const DataChannelInfo * infos
Definition: NGIAgoraDataChannel.h:70
agora::ILocalDataChannel::~ILocalDataChannel
virtual ~ILocalDataChannel()
Definition: NGIAgoraDataChannel.h:108
agora::IRemoteDataChannel::ChannelId
virtual int ChannelId() const =0
agora::IRemoteDataChannel::UserId
virtual util::AString UserId() const =0
agora::DataChannelConfig::channelId
Optional< int > channelId
Definition: NGIAgoraDataChannel.h:38
agora::DataChannelInfo::metadata
util::AString metadata
Definition: NGIAgoraDataChannel.h:56
agora::DataChannelInfo
Definition: NGIAgoraDataChannel.h:48
agora::IDataChannelObserver::onLocalDataChannelPublished
virtual void onLocalDataChannelPublished(agora_refptr< ILocalDataChannel > channel)
Definition: NGIAgoraDataChannel.h:127
agora::DataChannelInfo::dataChannelId
int dataChannelId
Definition: NGIAgoraDataChannel.h:52
agora::UserDataChannelInfo
Definition: NGIAgoraDataChannel.h:62
agora::IDataChannelObserver::onRemoteDataChannelUnsubscribed
virtual void onRemoteDataChannelUnsubscribed(agora_refptr< IRemoteDataChannel > channel)
Definition: NGIAgoraDataChannel.h:139
agora::UserDataChannelInfo::info_size
size_t info_size
Definition: NGIAgoraDataChannel.h:74
AgoraRefPtr.h
agora::ILocalDataChannel::configuredChannelId
virtual Optional< int > configuredChannelId() const =0
agora::RefCountInterface
Definition: AgoraRefPtr.h:31
agora::DataChannelConfig::compressionLength
int compressionLength
Definition: NGIAgoraDataChannel.h:36
agora::util::CopyableAutoPtr
Definition: AgoraBase.h:145
agora::ILocalDataChannel
Definition: NGIAgoraDataChannel.h:77
agora::DataChannelConfig
Definition: NGIAgoraDataChannel.h:17
agora::IDataChannelObserver
Definition: NGIAgoraDataChannel.h:121
agora::Optional< int >