17#ifndef __HIVE_CHAT_H__
18#define __HIVE_CHAT_H__
72class HIVESDK_DLLEXPORT
Chat {
75 typedef std::function<void(
ResultAPI const & result)> onResult;
76 typedef std::function<void(
ResultAPI const & result)> onCreateChannel;
77 typedef std::function<void(
ResultAPI const & result)> onDeleteChannel;
78 typedef std::function<void(
ResultAPI const & result)> onEnterChannel;
79 typedef std::function<void(
ResultAPI const & result)> onExitChannel;
80 typedef std::function<void(
ResultAPI const & result)> onBlockMember;
81 typedef std::function<void(
ResultAPI const & result)> onUnblockMember;
82 typedef std::function<void(
ResultAPI const & result)> onChannelTranslationSetting;
83 typedef std::function<void(
ResultAPI const & result)> onConnect;
84 typedef std::function<void(
ResultAPI const & result)> onDisconnect;
85 typedef std::function<void(
ResultAPI const & result, std::vector<std::string>
const & channelIds, std::vector<std::string>
const & failChannelIds)> onReconnect;
86 typedef std::function<void(
ResultAPI const & result, std::vector<Channel>
const & channels,
ChannelPage const & channelPage)> onGetChannels;
87 typedef std::function<void(
ResultAPI const & result,
Channel const & channel, std::vector<Member>
const & members)> onGetChannelInfo;
88 typedef std::function<void(
ResultAPI const & result, std::vector<Member>
const & members)> onGetChannelMembers;
89 typedef std::function<void(
ResultAPI const & result, std::vector<Channel>
const & channels)> onGetChannelsByUser;
90 typedef std::function<void(
ResultAPI const & result, std::vector<BlockMember>
const & blockMembers)> onGetBlockMembers;
184 static void deleteChannel(
const char * channelId, onDeleteChannel listener);
220 static void exitChannel(
const char * channelId, onExitChannel listener);
274 static void blockMember(int64_t blockPlayerId, onBlockMember listener);
308 static void translate(TranslateParams
const & params, onTranslate listener);
328 static void connect(
const char * extraData, onResult listener);
626 static void executeEngine(picojson::value jsonParam);
662 std::string channelId;
668 std::string channelName;
676 int64_t regTimeMillis;
678 bool chatHistoryAllowed;
681 bool parse(picojson::value
const & json);
682 picojson::object toJson()
const;
683 std::string toString()
const;
686 void setTranslationEnabled(
bool enabled, Chat::onChannelTranslationSetting listener)
const;
706 bool parse(picojson::value
const & json);
707 picojson::object toJson()
const;
720 std::string connectedTime;
722 int64_t connectedTimeMillis;
725 bool parse(picojson::value
const & json);
726 picojson::object toJson()
const;
739 std::string blockedTime;
741 int64_t blockedTimeMillis;
744 bool parse(picojson::value
const & json);
745 picojson::object toJson()
const;
757 std::string channelId;
759 std::string password;
761 std::string channelName;
767 bool chatHistoryAllowed;
770 picojson::object toJson()
const;
771 std::string toString()
const;
784 std::string channelId;
786 std::string channelName;
790 std::string pageOrder;
797 picojson::object toJson()
const;
798 std::string toString()
const;
809 std::string channelId;
811 std::string password;
814 picojson::object toJson()
const;
815 std::string toString()
const;
826 std::string channelId;
830 std::string extraData;
833 picojson::object toJson()
const;
834 std::string toString()
const;
835 bool parse(picojson::value
const & json);
850 std::string extraData;
853 picojson::object toJson()
const;
854 std::string toString()
const;
855 bool parse(picojson::value
const & json);
871 picojson::object toJson()
const;
872 std::string toString()
const;
875class HIVESDK_DLLEXPORT TranslateParams {
878 std::string sourceLanguage;
879 std::vector<std::string> targetLanguage;
882 picojson::object toJson()
const;
883 std::string toString()
const;
895 std::string channelId;
899 std::string timestamp;
901 int64_t timestampMillis;
904 bool parse(picojson::value
const & json);
915 std::string channelId;
919 std::string timestamp;
921 int64_t timestampMillis;
924 bool parse(picojson::value
const & json);
935 std::string channelId;
937 std::string timestamp;
939 int64_t timestampMillis;
942 bool parse(picojson::value
const & json);
954 std::string channelId;
960 std::string timestamp;
962 int64_t timestampMillis;
965 bool parse(picojson::value
const & json);
978 std::string extraData;
984 std::string timestamp;
986 int64_t timestampMillis;
990 std::string translatedMessage;
994 bool parse(picojson::value
const & json);
1007 std::string extraData;
1011 std::string message;
1013 std::string timestamp;
1015 int64_t timestampMillis;
1018 bool parse(picojson::value
const & json);
1031 std::string message;
1033 std::string timestamp;
1035 int64_t timestampMillis;
1038 bool parse(picojson::value
const & json);
1049 std::string nextIndex;
1050 std::vector<ChannelMessage> messages;
1053 bool parse(picojson::value
const & json);
1063 map<std::string, std::string> translations;
1066 bool parse(picojson::value
const & json);
1078 virtual void onEnteredMember(
EnteredMember const & member) = 0;
1080 virtual void onExitedMember(
ExitedMember const & member) = 0;
1082 virtual void onDeletedChannel(
DeletedChannel const & channel) = 0;
1086 virtual void onChannelMessage(
ChannelMessage const & message) = 0;
1100 virtual void onDirectMessage(
DirectMessage const & message) = 0;
1111 virtual void onDirectMessage(
DirectMessage const & message) = 0;
1113 virtual void onNoticeMessage(
NoticeMessage const & message) = 0;
1126 virtual void onConnected() = 0;
1128 virtual void onReconnectStarted() = 0;
1130 virtual void onReconnected(
ResultAPI const & result, std::vector<std::string>
const & channelIds, std::vector<std::string>
const & failChannelIds) = 0;
1132 virtual void onDisconnected() = 0;
1145 virtual void onCustomData(std::string
const & data) = 0;
1150class HIVESDK_DLLEXPORT Unique64 {
1153 static Unique64& getInstance();
1154 std::string generateKey();
1157 uint64_t last_timestamp_ms_;
1160 static const uint16_t MAX_SEQUENCE = 0xFFFF;
1163 uint64_t getCurrentTimestampMs();
1164 uint64_t waitUntilNextMillisecond(uint64_t current_ts_ms_ref);
1167template<
typename Key,
typename Value>
1168class ThreadSafeMap {
1170 std::map<Key, Value> map_;
1171 mutable std::mutex mutex_;
1174 ThreadSafeMap() =
default;
1175 ThreadSafeMap(
const ThreadSafeMap&) =
delete;
1176 ThreadSafeMap& operator=(
const ThreadSafeMap&) =
delete;
1177 void insert(
const Key& key,
const Value& value);
1178 Value get(
const Key& key)
const;
1179 bool contains(
const Key& key)
const;
1180 size_t erase(
const Key& key);
차단된 사용자 정보
Definition: HIVE_Chat.h:734
채팅 채널 정보
Definition: HIVE_Chat.h:659
채널 이벤트 리스너
Definition: HIVE_Chat.h:1075
채널 메시지 정보
Definition: HIVE_Chat.h:973
채널 대화 이력 조회 파라미터
Definition: HIVE_Chat.h:863
채널 대화 이력 정보
Definition: HIVE_Chat.h:1046
채널 공지 메시지 정보
Definition: HIVE_Chat.h:951
채널 조회 페이지 정보
Definition: HIVE_Chat.h:694
채널 메시지 전송 파라미터
Definition: HIVE_Chat.h:823
HiveChat provides essential features for smooth chatting in games, such as real-time,...
Definition: HIVE_Chat.h:72
연결 리스너
Definition: HIVE_Chat.h:1123
채널 생성 파라미터
Definition: HIVE_Chat.h:754
커스텀 데이터 리스너
Definition: HIVE_Chat.h:1142
삭제된 채널 정보
Definition: HIVE_Chat.h:932
1:1 메시지 정보
Definition: HIVE_Chat.h:1002
1:1 메시지 리스너
Definition: HIVE_Chat.h:1097
1:1 메시지 전송 파라미터
Definition: HIVE_Chat.h:843
채널 입장 파라미터
Definition: HIVE_Chat.h:806
입장 멤버 정보
Definition: HIVE_Chat.h:892
퇴장 멤버 정보
Definition: HIVE_Chat.h:912
채널 목록 조회 파라미터
Definition: HIVE_Chat.h:779
채널 멤버 정보
Definition: HIVE_Chat.h:715
유저 대상 공지 메시지 정보
Definition: HIVE_Chat.h:1026
Definition: HIVE_ResultAPI.h:64
메시지 번역 결과
Definition: HIVE_Chat.h:1061
유저 이벤트 리스너
Definition: HIVE_Chat.h:1108
static void removeCustomDataListener(const char *uniqueKey)
Remove Custom Data Listener
static void removeChannelListener(const char *uniqueKey)
Remove Channel Listener Remove the registered channel listener.
static void addConnectionListener(const char *uniqueKey, ConnectionListener *listener)
Register Connection Listener Register a listener to receive the connection status of the Chat Server...
static void sendMessageWithDirectSendMessageParams(DirectSendMessageParams const ¶ms)
Send a 1:1 message Receives the recipient ID and message and sends the message to the corresponding ...
ChannelType
채팅 채널 타입 정보
Definition: HIVE_Chat.h:635
static void addChannelListener(const char *uniqueKey, ChannelListener *listener)
Register Channel Listener Register a listener to receive channel events.
static void addUserListener(const char *uniqueKey, UserListener *listener)
Register User Listener Register a listener to receive user events.
static void disconnect(onDisconnect listener)
Disconnects the Chat Server Disconnects from the Chat Server.
static void getChannelMembers(const char *channelId, onGetChannelMembers listener)
Get channel members Receives the channel ID and retrieves the list of members in the corresponding c...
static void getChannelsByUser(onGetChannelsByUser listener)
Get a list of channels the user is participating in.
static void unblockMember(int64_t blockPlayerId, onUnblockMember listener)
Unblock user Receives the user ID and unblocks the corresponding user.
static void connect(const char *extraData, onResult listener)
Connects the Chat Server (Deprecated) This method is no longer recommended and will be removed in fu...
static void translate(TranslateParams const ¶ms, onTranslate listener)
Message translation request.
static void connect(onConnect listener)
Connects the Chat Server Attempts to connect to the Chat Server.
static void deleteChannel(const char *channelId, onDeleteChannel listener)
Delete channel Receives the channel ID and deletes the corresponding channel.
static bool isConnected()
Check the socket connection status Check if the socket is currently connected.
static void getBlockMembers(onGetBlockMembers listener)
Get a list of blocked users.
static void addDirectMessageListener(const char *uniqueKey, DirectMessageListener *listener)
Register Direct Message Listener Register a listener to receive 1:1 messages.
static void getChannels(GetChannelsParams const *params, onGetChannels listener)
Get channel list Retrieves a list of accessible channels.
static void enterChannel(EnterChannelParams const ¶ms, onEnterChannel listener)
Enter channel Receives the channel ID and connects to the channel.
static void removeUserListener(const char *uniqueKey)
Remove User Listener Remove the registered user event listener.
static void exitChannel(const char *channelId, onExitChannel listener)
Exit channel Receives the channel ID and exits the corresponding channel.
static void removeConnectionListener(const char *uniqueKey)
Remove Connection Listener Remove the registered connection listener.
static void blockMember(int64_t blockPlayerId, onBlockMember listener)
Block user Receives the user ID and blocks the corresponding user.
static void sendMessageWithDirectSendMessageParams(DirectSendMessageParams const ¶ms, onDirectSendMessage listener)
Send a 1:1 message Receives the recipient ID and message and sends the message to the corresponding ...
static void reconnect(onReconnect listener)
The reconnection will rejoin the previously connected channels if the disconnection occurred less tha...
static void sendMessageWithChannelSendMessageParams(ChannelSendMessageParams const ¶ms, onChannelSendMessage listener)
Send a channel message Receives the channel ID and message and sends the message to the correspondin...
SortType
채널 정렬 타입 정보
Definition: HIVE_Chat.h:647
static void addCustomDataListener(const char *uniqueKey, CustomDataListener *listener)
Register Custom Data Listener
static void sendMessageWithChannelSendMessageParams(ChannelSendMessageParams const ¶ms)
Send a channel message Receives the channel ID and message and sends the message to the correspondin...
static void createChannel(CreateChannelParams const ¶ms, onCreateChannel listener)
Create a channel Channel Name, Maximum Number of People, and Type can be specified,...
static void getChannelInfo(const char *channelId, onGetChannelInfo listener)
Get channel information Receives the channel ID and retrieves the information of the corresponding c...
static void removeDirectMessageListener(const char *uniqueKey)
Remove Direct Message Listener Remove the registered 1:1 message listener.