Sendbird Chat SDK for Unreal
SBDGroupChannel.h
1// Copyright (c) 2021 Sendbird, Inc. All rights reserved.
2
3#ifndef SENDBIRD_SBDGROUPCHANNEL_H_
4#define SENDBIRD_SBDGROUPCHANNEL_H_
5
6#include "SBDBaseChannel.h"
7#include "SBDBaseMessage.h"
8#include "SBDUser.h"
9#include "SBDError.h"
10#include "SBDReadStatus.h"
11#include "SBDMember.h"
12#include "SBDGroupChannelListQuery.h"
13#include "SBDGroupChannelParams.h"
14
15class SBDUser;
16class SBDGroupChannel;
18class FSBDGroupChannel;
19
39class SBDGroupChannel final : public SBDBaseChannel {
40public:
45
50
57
62
66 std::vector<SBDMember> members;
67
71 uint64_t member_count;
72
77
82
87
91 SBDGroupChannelHiddenState hidden_state;
92
104 static void CreateChannel(std::vector<std::wstring> user_ids, const std::wstring& name, bool is_distinct, const std::wstring& cover_url,
105 const std::wstring& data, const std::wstring& custom_type, std::function<void(SBDGroupChannel*, SBDError*)> completion_handler);
106
119 static void CreateChannel(const std::vector<std::wstring> user_ids, const std::wstring& name, bool is_distinct, const std::wstring& cover_image_file_path,
120 const std::wstring& file_mime_type, const std::wstring& data, const std::wstring& custom_type,
121 std::function<void(SBDGroupChannel*, SBDError*)> completion_handler);
122
130 static void CreateChannel(SBDGroupChannelParams& params, std::function<void(SBDGroupChannel*, SBDError*)> completion_handler);
131
142 void UpdateChannel(const std::wstring& name, bool is_distinct, const std::wstring& cover_url, const std::wstring& data, const std::wstring& custom_type,
143 std::function<void(SBDGroupChannel*, SBDError*)> completion_handler);
144
156 void UpdateChannel(const std::wstring& name, bool is_distinct, const std::wstring& cover_image_file_path, const std::wstring& file_mime_type,
157 const std::wstring& data, const std::wstring& custom_type, std::function<void(SBDGroupChannel*, SBDError*)> completion_handler);
158
165 void DeleteChannel(std::function<void(SBDError*)> completion_handler);
166
172 void RefreshChannel(std::function<void(SBDError*)> completion_handler);
173
180
187 static void GetChannelFromServer(const std::wstring& channel_url, std::function<void(SBDGroupChannel*, SBDError*)> completion_handler);
188
195 static void GetChannel(const std::wstring& channel_url, std::function<void(SBDGroupChannel*, SBDError*)> completion_handler);
196
203 void InviteUsers(const std::vector<SBDUser>& users, std::function<void(SBDError*)> completion_handler);
204
211 void HideChannel(bool hide_prev_messages, std::function<void(SBDError*)> completion_handler);
212
218 void HideChannel(bool hide_prev_messages, bool allow_auto_unhide, std::function<void(SBDError*)> completion_handler);
219
225 void UnhideChannel(std::function<void(SBDError*)> completion_handler);
226
232 void JoinChannel(std::function<void(SBDError*)> completion_handler);
233
239 void LeaveChannel(std::function<void(SBDError*)> completion_handler);
240
246 static void MarkAllAsRead(std::function<void(SBDError*)> completion_handler);
247
254
262
269 int64_t GetLastSeenAt(const SBDUser& user);
270
277 std::vector<SBDMember> GetReadMembers(SBDBaseMessage* message);
278
285 std::vector<SBDMember> GetUnreadMembers(SBDBaseMessage* message);
286
291 std::map<std::wstring, SBDReadStatus> GetReadStatus();
292
299 bool HasMember(const std::wstring& user_id);
300
308 SBDMember GetMember(const std::wstring& user_id, bool* member_exist);
309
315 void AcceptInvitation(std::function<void(SBDError*)> completion_handler);
316
322 void DeclineInvitation(std::function<void(SBDError*)> completion_handler);
323
329 void ResetMyHistory(std::function<void(SBDError*)> completion_handler);
330
337 static void GetChannelCount(SBDMemberStateFilter member_state_filter,
338 std::function<void(uint64_t group_chanel_count, SBDError* error)> completion_handler);
339
346
347private:
348 int64_t last_start_typing_ts;
349 int64_t last_end_typing_ts;
350 int64_t last_manual_mark_as_read_ts;
351 std::map<std::wstring, SBDMember> member_map;
352 static std::mutex member_mutex;
353 std::map<std::wstring, int64_t> cached_read_receipt_status;
354 std::map<std::wstring, int64_t> cached_typing_status;
355 static std::vector<std::unique_ptr<SBDGroupChannelListQuery>> group_channel_list_queries;
356 bool has_been_updated;
357
358 SBDGroupChannel(const std::string& dict);
359 static SBDGroupChannel* Upsert(SBDGroupChannel* channel);
360 void Overwrite(SBDGroupChannel* channel);
361 void UpdateTypingStatus(const SBDUser& user, bool start);
362 void AddMember(SBDMember user);
363 void RemoveMember(SBDMember user);
364 void TypingStatusTimeout();
365 void UpdateReadReceipt(const std::wstring& user_id, int64_t timestamp);
366 void SetChannelHiddenState(SBDGroupChannelHiddenState hidden_state);
367 void UpdateMyReadReceipt(int64_t ts);
368 static std::map<std::wstring, std::unique_ptr<SBDGroupChannel>> cached_channels;
369 static std::mutex cached_channel_mutex;
370 static int64_t last_mark_all_as_read_ts;
371 static SBDGroupChannel* BuildAndUpsert(std::string dict);
372 static void UpdateTypingStatus();
373 static void ClearCache();
374 static void RemoveChannelFromCache(const std::wstring& channel_url);
375 static SBDGroupChannel* GetChannelFromCache(const std::wstring& channel_url);
376 static bool HasChannelInCache(const std::wstring& channel_url);
377 static void LocalGetChannel(bool from_local, const std::wstring& channel_url, std::function<void(SBDGroupChannel*, SBDError*)> completion_handler);
378
379 void StartTyping();
380 void EndTyping();
381 bool IsTyping();
382 std::vector<SBDMember> GetTypingMembers();
383
384 friend FSBDGroupChannel;
385};
386
387#endif /* SENDBIRD_SBDGROUPCHANNEL_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: SBDBaseMessage.h:19
Definition: SBDError.h:13
Definition: SBDGroupChannel.h:39
void AcceptInvitation(std::function< void(SBDError *)> completion_handler)
SBDUser inviter
Definition: SBDGroupChannel.h:76
static SBDGroupChannelListQuery * CreateMyGroupChannelListQuery()
void UpdateChannel(const std::wstring &name, bool is_distinct, const std::wstring &cover_image_file_path, const std::wstring &file_mime_type, const std::wstring &data, const std::wstring &custom_type, std::function< void(SBDGroupChannel *, SBDError *)> completion_handler)
void HideChannel(bool hide_prev_messages, bool allow_auto_unhide, std::function< void(SBDError *)> completion_handler)
std::vector< SBDMember > GetUnreadMembers(SBDBaseMessage *message)
static void GetChannelFromServer(const std::wstring &channel_url, std::function< void(SBDGroupChannel *, SBDError *)> completion_handler)
void ResetMyHistory(std::function< void(SBDError *)> completion_handler)
void DeleteChannel(std::function< void(SBDError *)> completion_handler)
static void GetChannel(const std::wstring &channel_url, std::function< void(SBDGroupChannel *, SBDError *)> completion_handler)
void LeaveChannel(std::function< void(SBDError *)> completion_handler)
bool HasMember(const std::wstring &user_id)
void DeclineInvitation(std::function< void(SBDError *)> completion_handler)
static void GetChannelCount(SBDMemberStateFilter member_state_filter, std::function< void(uint64_t group_chanel_count, SBDError *error)> completion_handler)
static void MarkAllAsRead(std::function< void(SBDError *)> completion_handler)
int64_t GetLastSeenAt(const SBDUser &user)
const SBDBaseMessage * GetLastMessage()
SBDMember GetMember(const std::wstring &user_id, bool *member_exist)
std::vector< SBDMember > members
Definition: SBDGroupChannel.h:66
static void CreateChannel(std::vector< std::wstring > user_ids, const std::wstring &name, bool is_distinct, const std::wstring &cover_url, const std::wstring &data, const std::wstring &custom_type, std::function< void(SBDGroupChannel *, SBDError *)> completion_handler)
static void CreateChannel(const std::vector< std::wstring > user_ids, const std::wstring &name, bool is_distinct, const std::wstring &cover_image_file_path, const std::wstring &file_mime_type, const std::wstring &data, const std::wstring &custom_type, std::function< void(SBDGroupChannel *, SBDError *)> completion_handler)
SBDGroupChannelHiddenState hidden_state
Definition: SBDGroupChannel.h:91
std::map< std::wstring, SBDReadStatus > GetReadStatus()
int64_t last_message_id
Definition: SBDGroupChannel.h:44
void UpdateChannel(const std::wstring &name, bool is_distinct, const std::wstring &cover_url, const std::wstring &data, const std::wstring &custom_type, std::function< void(SBDGroupChannel *, SBDError *)> completion_handler)
void RefreshChannel(std::function< void(SBDError *)> completion_handler)
int GetReadReceipt(SBDBaseMessage *message)
void InviteUsers(const std::vector< SBDUser > &users, std::function< void(SBDError *)> completion_handler)
std::vector< SBDMember > GetReadMembers(SBDBaseMessage *message)
void HideChannel(bool hide_prev_messages, std::function< void(SBDError *)> completion_handler)
bool is_public
Definition: SBDGroupChannel.h:56
static void CreateChannel(SBDGroupChannelParams &params, std::function< void(SBDGroupChannel *, SBDError *)> completion_handler)
uint64_t unread_message_count
Definition: SBDGroupChannel.h:61
void JoinChannel(std::function< void(SBDError *)> completion_handler)
bool is_hidden
Definition: SBDGroupChannel.h:86
uint64_t member_count
Definition: SBDGroupChannel.h:71
bool has_inviter
Definition: SBDGroupChannel.h:81
bool is_distinct
Definition: SBDGroupChannel.h:49
void UnhideChannel(std::function< void(SBDError *)> completion_handler)
Definition: SBDGroupChannelListQuery.h:15
Definition: SBDGroupChannelParams.h:16
Definition: SBDMember.h:16
Definition: SBDUser.h:20