3#ifndef SENDBIRD_SENDBIRD_H_
4#define SENDBIRD_SENDBIRD_H_
6#include "SBDAdminMessage.h"
7#include "SBDBaseChannel.h"
8#include "SBDBaseInterface.h"
9#include "SBDBaseMessage.h"
11#include "SBDFileMessage.h"
12#include "SBDFileMessageParams.h"
13#include "SBDGroupChannel.h"
14#include "SBDGroupChannelListQuery.h"
15#include "SBDGroupChannelParams.h"
16#include "SBDGroupChannelTotalUnreadMessageCountParams.h"
18#include "SBDMessageMetaArray.h"
19#include "SBDOpenChannel.h"
20#include "SBDOpenChannelListQuery.h"
21#include "SBDOpenChannelParams.h"
22#include "SBDOperatorListQuery.h"
23#include "SBDPreviousMessageListQuery.h"
24#include "SBDReadStatus.h"
27#include "SBDUserListQuery.h"
28#include "SBDUserMessage.h"
29#include "SBDUserMessageParams.h"
38#include <condition_variable>
42#define SBD_NULL_STRING "SBD_NULL_STRING_f2648f84e7e941208c8d9df02230a7c8"
43#define SBD_NULL_WSTRING L"SBD_NULL_STRING_f2648f84e7e941208c8d9df02230a7c8"
44#define IsNullString(str) (((str).compare(SBD_NULL_STRING)) == 0)
45#define IsNullWString(str) (((str).compare(SBD_NULL_WSTRING)) == 0)
47class SBDWebSocketClient;
48class SBDLoginTimerHandler;
49class SBDUpdateUserInfoWithBinaryFileRequestHandler;
50class SBDWebSocketSendCommandHandler;
51class SBDReconnectTimerHandler;
52class SBDTypingStatusTimerHandler;
53class SBDAckTimerHandler;
54class SBDUnReadMessageCount;
56class SBDThreadManager;
75 virtual void Started() {};
76 virtual void Succeeded() {};
77 virtual void Failed() {};
131 static void Init(std::wstring application_id);
216 static void Connect(std::wstring user_id, std::wstring access_token, std::function<
void(
SBDUser*,
SBDError*)> completion_handler);
223 static void Disconnect(std::function<
void()> completion_handler);
251 std::function<
void(
SBDError*)> completion_handler);
396 std::wstring application_id;
398 std::mutex current_user_mutex;
400 std::map<std::wstring, SBDConnectionHandler*> reconnection_handlers;
401 std::mutex reconnection_handlers_mutex;
402 std::map<std::wstring, SBDUserEventHandler*> user_event_handlers;
403 std::mutex user_event_handlers_mutex;
404 std::map<std::wstring, SBDChannelHandler*> channel_handlers;
405 std::mutex channel_handlers_mutex;
407 std::unique_ptr<SBDWebSocketClient> websocket_client;
408 std::mutex websocket_client_mutex;
410 std::mutex reconnect_in_progress_mutex;
411 bool reconnect_in_progress;
412 SBDReconnectTimerHandler* reconnect_timer =
nullptr;
413 std::mutex reconnect_timer_mutex;
415 SBDTypingStatusTimerHandler* typing_status_timer =
nullptr;
416 std::mutex typing_status_timer_mutex;
419 bool has_current_user;
421 std::vector<std::unique_ptr<SBDUserListQuery>> user_list_queries;
422 std::vector<std::unique_ptr<SBDUpdateUserInfoWithBinaryFileRequestHandler>> update_user_info_with_binary_file_request_handlers;
424 SBDLoginTimerHandler* login_timer =
nullptr;
425 std::mutex login_timer_mutex;
427 unsigned long reconnect_delay;
428 uint8_t reconnect_count;
429 std::map<std::string, SBDAckTimerHandler*> ack_timer_map;
430 std::mutex ack_timer_map_mutex;
432 std::vector<std::function<void(
SBDUser*,
SBDError*)>> connect_callbacks;
433 std::mutex connect_callbacks_mutex;
434 std::wstring connecting_user_id;
436 std::vector<std::function<void()>> disconnect_callbacks;
437 std::mutex disconnect_callbacks_mutex;
438 bool is_disconnecting;
440 std::unique_ptr<SBDUnReadMessageCount> un_read_message_count;
441 std::unique_ptr<SBDThreadManager> thread_manager;
443 std::wstring pending_push_token;
448 void operator=(
SBDMain const&) =
delete;
449 void ReceiveMessage(std::string message,
bool reconnect);
450 void Send(SBDCommand* command, std::function<
void(SBDCommand*,
SBDError*)> completion_handler);
452 static void Disconnect(
bool logout,
bool from_disconnect, std::function<
void()> completion_handler);
453 static void ClearUserData();
454 static void ClearLocalData();
458 static std::map<std::wstring, SBDConnectionHandler*> GetReconnectionHandlers();
459 static std::map<std::wstring, SBDUserEventHandler*> GetUserEventHandlers();
460 static std::map<std::wstring, SBDChannelHandler*> GetChannelHandlers();
462 static void ClearCurrentUser();
463 static void ProcessSubscribedUnreadMessageCount(SBDCommand* command);
464 static void ClearUnreadCount();
465 static void Reconnect(
unsigned long timeout);
466 static void ConnectToWebSocketServer(
bool reconnect,
467 std::wstring user_id, std::wstring access_token, std::string session_key,
469 static void SetHosts(std::wstring api_host, std::wstring ws_host);
470 static std::wstring GetApiServer();
471 static std::wstring GetCustomApiServer();
472 static std::wstring GetApiHostScheme();
473 static std::wstring GetApiHost();
474 static int GetApiPort();
475 static std::wstring GetWsServer();
476 static std::wstring GetCustomWsServer();
477 static std::wstring GetWsHostScheme();
478 static std::wstring GetWsHost();
479 static int GetWsPort();
480 static SBDWebSocketClient* GetWebSocket();
481 static bool HasCurrentUser();
482 static std::wstring GetCurrentUserId();
483 static void SetCurrentUser(
const SBDUser& user);
485 static void StartAckTimer(SBDCommand* command, std::function<
void(SBDCommand*,
SBDError*)> command_completion_handler);
486 static void RunAckTimerCallback(SBDCommand* command,
SBDError* error);
487 static void StopAckTimer(SBDCommand* command);
488 static std::map<std::string, SBDAckTimerHandler*>& GetAckTimerMap();
489 static std::mutex& GetAckTimerMapMutex();
490 static void InvalidateAckTimers();
491 static void ProcessAckTimersToErrors();
492 static void StartLoginTimer(std::wstring user_id, std::function<
void(
SBDUser*,
SBDError*)> completion_handler);
493 static void StopLoginTimer();
495 static void IncreaseReconnectCount();
496 static void ResetReconnectCount();
497 static uint8_t GetReconnectCount();
498 static unsigned long GetReconnectDelay();
499 static void IncreaseReconnectDelay();
500 static void ResetReconnectDelay();
501 static void SetReconnectionProgress(
bool is_in_progress);
502 static bool GetReconnectionProgress();
503 static void SetReconnectTimer(
unsigned long time_interval);
504 static void StopReconnectTimer();
506 static void Connect(std::wstring user_id, std::wstring access_token, std::wstring api_host, std::wstring ws_host,
509 static void ProcessDisconnectCallbacks(
bool logout);
510 static std::wstring GetPlatformName();
511 static std::wstring GetPlatformVersion();
512 static std::wstring GetDeviceOsName();
513 static std::wstring GetDeviceOsVersion();
514 static SBDThreadManager* GetThreadManager();
Definition: SBDBaseChannel.h:42
Definition: Sendbird.h:73
Definition: SBDError.h:13
Definition: SBDGroupChannelTotalUnreadMessageCountParams.h:16
Definition: Sendbird.h:103
static void RemoveUserEventHandler(std::wstring identifier)
static SBDUserListQuery * CreateBlockedUserListQuery()
static void UnblockUser(const SBDUser &user, std::function< void(SBDError *)> completion_handler)
static void RemoveConnectionHandler(std::wstring identifier)
static void RemoveAllConnectionHandlers()
static void RemoveAllChannelHandlers()
static void Init(std::wstring application_id)
static void UnregisterPushTokenForCurrentUser(SBDPushTokenType type, std::wstring token, std::function< void(SBDError *)> completion_handler)
static void Connect(std::wstring user_id, std::wstring access_token, std::function< void(SBDUser *, SBDError *)> completion_handler)
static int GetSubscribedCustomTypeTotalUnreadMessageCount()
static SBDUser * GetCurrentUser()
static void BlockUser(const SBDUser &user, std::function< void(SBDUser *blocked_user, SBDError *)> completion_handler)
static void AddConnectionHandler(std::wstring identifier, SBDConnectionHandler *handler)
static std::wstring GetApplicationId()
static void Disconnect(std::function< void()> completion_handler)
static void RegisterPushTokenForCurrentUser(SBDPushTokenType type, std::wstring token, bool unique, std::function< void(SBDPushTokenRegistrationStatus, SBDError *)> completion_handler)
static void GetTotalUnreadChannelCount(std::function< void(int total_unread_channel_count, SBDError *)> completion_handler)
static void UpdateCurrentUserInfo(std::wstring nickname, std::wstring profile_url, std::function< void(SBDError *)> completion_handler)
static void GetChannelInvitationPreference(std::function< void(bool is_auto_accept, SBDError *)> completion_handler)
static void AddChannelHandler(std::wstring identifier, SBDChannelHandler *handler)
static void GetTotalUnreadMessageCount(SBDGroupChannelTotalUnreadMessageCountParams ¶ms, std::function< void(int total_unread_message_count, SBDError *)> completion_handler)
static SBDConnectionState GetConnectionState()
static std::wstring GetPendingPushToken()
static void RemoveAllUserEventHandlers()
static int GetSubscribedTotalUnreadMessageCount()
static SBDUserListQuery * CreateUserListQuery(std::vector< std::wstring > user_ids)
static SBDUserListQuery * CreateAllUserListQuery()
static void UpdateCurrentUserInfoWithBinaryProfileImage(std::wstring nickname, std::wstring profile_image_file_path, std::wstring mime_type, std::function< void(SBDError *)> completion_handler)
static void UnregisterPushTokenAllForCurrentUser(std::function< void(SBDError *)> completion_handler)
static void RemoveChannelHandler(std::wstring identifier)
static int GetSubscribedCustomTypeUnreadMessageCount(std::wstring custom_type)
static void AddUserEventHandler(std::wstring identifier, SBDUserEventHandler *handler)
static std::wstring GetSdkVersion()
static bool IsInitialized()
static void SetChannelInvitationPreference(bool auto_accept, std::function< void(SBDError *)> completion_handler)
Definition: Sendbird.h:61
static bool use_member_as_message_sender
Definition: Sendbird.h:67
Definition: Sendbird.h:85
virtual void TotalUnreadMessageCountChanged(int total_count, std::map< std::wstring, int > total_count_by_custom_type)
Definition: Sendbird.h:95
Definition: SBDUserListQuery.h:35