Sendbird Chat SDK for Unreal
SBDOpenChannel.h
1// Copyright (c) 2021 Sendbird, Inc. All rights reserved.
2
3#ifndef SENDBIRD_SBDOPENCHANNEL_H_
4#define SENDBIRD_SBDOPENCHANNEL_H_
5
6#include "SBDBaseChannel.h"
7#include "SBDUser.h"
8#include "SBDError.h"
9#include "SBDOpenChannelListQuery.h"
10#include "SBDUserListQuery.h"
11#include "SBDOpenChannelParams.h"
12
13class SBDOpenChannel;
15class FSBDOpenChannel;
16
25class SBDOpenChannel final : public SBDBaseChannel {
26public:
31
35 std::vector<SBDUser> operators;
36
41
48
60 static void CreateChannel(const std::wstring& name, const std::wstring& channel_url, const std::wstring& cover_url,
61 const std::wstring& data, const std::vector<std::wstring>& operator_user_ids, const std::wstring& custom_type,
62 std::function<void(SBDOpenChannel*, SBDError*)> completion_handler);
63
76 static void CreateChannel(const std::wstring& name, const std::wstring& channel_url, const std::wstring& cover_image_file_path,
77 const std::wstring& file_mime_type, const std::wstring& data, const std::vector<std::wstring>& operator_user_ids,
78 const std::wstring& custom_type, std::function<void(SBDOpenChannel*, SBDError*)> completion_handler);
79
87 static void CreateChannel(SBDOpenChannelParams& params, std::function<void(SBDOpenChannel*, SBDError*)> completion_handler);
88
99 void UpdateChannel(const std::wstring& new_name, const std::wstring& new_cover_url, const std::wstring& new_data, const std::vector<std::wstring>& new_operator_user_ids,
100 const std::wstring& new_custom_type, std::function<void(SBDOpenChannel*, SBDError*)> completion_handler);
101
113 void UpdateChannel(const std::wstring& new_name, const std::wstring& new_cover_image_file_path, const std::wstring& new_cover_file_mime_type,
114 const std::wstring& new_data, const std::vector<std::wstring>& new_operator_user_ids, const std::wstring& new_custom_type,
115 std::function<void(SBDOpenChannel*, SBDError*)> completion_handler);
116
123 void DeleteChannel(std::function<void(SBDError*)> completion_handler);
124
131 static void GetChannel(const std::wstring& channel_url, std::function<void(SBDOpenChannel*, SBDError*)> completion_handler);
132
138 void Enter(std::function<void(SBDError*)> completion_handler);
139
145 void Exit(std::function<void(SBDError*)> completion_handler);
146
153
160
167
173 void RefreshChannel(std::function<void(SBDError*)> completion_handler);
174
182 void BanUser(const SBDUser& user, int seconds, std::function<void(SBDError*)> completion_handler);
183
190 void UnbanUser(const SBDUser& user, std::function<void(SBDError*)> completion_handler);
191
198 void MuteUser(const SBDUser& user, std::function<void(SBDError*)> completion_handler);
199
206 void UnmuteUser(const SBDUser& user, std::function<void(SBDError*)> completion_handler);
207
214 bool IsOperator(const SBDUser& user);
215
216private:
217 std::mutex operators_lock;
218 int64_t operators_updated_at;
219 static std::vector<std::unique_ptr<SBDOpenChannelListQuery>> open_channel_list_queries;
220 static std::vector<std::unique_ptr<SBDUserListQuery>> user_list_queries;
221 static std::map<std::wstring, std::shared_ptr<SBDOpenChannel>> cached_channels;
222 static std::map<std::wstring, std::shared_ptr<SBDOpenChannel>> entered_channels;
223 static std::mutex cached_channels_mutex;
224
225 SBDOpenChannel(const std::string& dict);
226 void UpdateOperators(std::vector<SBDUser> operators, int64_t update_ts);
227 static SBDOpenChannel* Upsert(SBDOpenChannel* channel);
228 void Overwrite(SBDOpenChannel* channel);
229 static void ClearCache();
230 static void ClearEnteredChannels();
231 static void RemoveChannelFromCache(const std::wstring& channel_url);
232 static void RemoveChannelFromEnteredChannels(const std::wstring& channel_url);
233 static SBDOpenChannel* BuildAndUpsert(const std::string& dict);
234 static void LocalGetChannel(bool from_local, const std::wstring& channel_url, std::function<void(SBDOpenChannel*, SBDError*)> completion_handler);
235
236 friend FSBDOpenChannel;
237};
238
239#endif /* SENDBIRD_SBDOPENCHANNEL_H_ */
Definition: SBDBaseChannel.h:271
std::wstring name
Definition: SBDBaseChannel.h:281
std::wstring data
Definition: SBDBaseChannel.h:296
std::wstring channel_url
Definition: SBDBaseChannel.h:276
std::wstring custom_type
Definition: SBDBaseChannel.h:301
std::wstring cover_url
Definition: SBDBaseChannel.h:286
Definition: SBDError.h:13
Definition: SBDOpenChannel.h:25
static void GetChannel(const std::wstring &channel_url, std::function< void(SBDOpenChannel *, SBDError *)> completion_handler)
bool IsOperator(const SBDUser &user)
SBDUserListQuery * CreateBannedUserListQuery()
bool is_frozen
Definition: SBDOpenChannel.h:40
void UnmuteUser(const SBDUser &user, std::function< void(SBDError *)> completion_handler)
void BanUser(const SBDUser &user, int seconds, std::function< void(SBDError *)> completion_handler)
void UpdateChannel(const std::wstring &new_name, const std::wstring &new_cover_url, const std::wstring &new_data, const std::vector< std::wstring > &new_operator_user_ids, const std::wstring &new_custom_type, std::function< void(SBDOpenChannel *, SBDError *)> completion_handler)
void RefreshChannel(std::function< void(SBDError *)> completion_handler)
std::vector< SBDUser > operators
Definition: SBDOpenChannel.h:35
void Exit(std::function< void(SBDError *)> completion_handler)
void UpdateChannel(const std::wstring &new_name, const std::wstring &new_cover_image_file_path, const std::wstring &new_cover_file_mime_type, const std::wstring &new_data, const std::vector< std::wstring > &new_operator_user_ids, const std::wstring &new_custom_type, std::function< void(SBDOpenChannel *, SBDError *)> completion_handler)
void UnbanUser(const SBDUser &user, std::function< void(SBDError *)> completion_handler)
void DeleteChannel(std::function< void(SBDError *)> completion_handler)
void Enter(std::function< void(SBDError *)> completion_handler)
static void CreateChannel(const std::wstring &name, const std::wstring &channel_url, const std::wstring &cover_image_file_path, const std::wstring &file_mime_type, const std::wstring &data, const std::vector< std::wstring > &operator_user_ids, const std::wstring &custom_type, std::function< void(SBDOpenChannel *, SBDError *)> completion_handler)
int64_t participant_count
Definition: SBDOpenChannel.h:30
static void CreateChannel(SBDOpenChannelParams &params, std::function< void(SBDOpenChannel *, SBDError *)> completion_handler)
SBDUserListQuery * CreateParticipantListQuery()
void MuteUser(const SBDUser &user, std::function< void(SBDError *)> completion_handler)
static void CreateChannel(const std::wstring &name, const std::wstring &channel_url, const std::wstring &cover_url, const std::wstring &data, const std::vector< std::wstring > &operator_user_ids, const std::wstring &custom_type, std::function< void(SBDOpenChannel *, SBDError *)> completion_handler)
static SBDOpenChannelListQuery * CreateOpenChannelListQuery()
SBDUserListQuery * CreateMutedUserListQuery()
Definition: SBDOpenChannelListQuery.h:15
Definition: SBDOpenChannelParams.h:16
Definition: SBDUser.h:20
Definition: SBDUserListQuery.h:35