Functional APIs

API List

  • Core

Global FunctionFunction Name
HMRStateHMRGetState()
voidHMRInit(uint64_t appId)
voidHMROpen(uint64_t uid, const char *region, const char *token, HMRCompletion completion)
voidHMRClose()
voidHMRRefreshToken(const char *token)
voidHMRSetLogger(HMRLogFunction logFunction)
voidHMRAddStateListener(HMRStateListener *listener)
voidHMRRemoveStateListener(HMRStateListener *listener)
const char *HMRGetVersion()
  • ChatRoomService

FunctionFunction Name
voidHMRCreateChatRoom(HMRCompletion completion)
voidHMRCreateChatRoomWithInfo(HMRKvArray *info, HMRCompletion completion)
voidHMRJoinChatRoom(uint64_t roomId, HMRCompletion completion)
voidHMRJoinChatRoomWithMultiCheck(uint64_t roomId, bool isCheckMultiJoin, HMRCompletion completion)
voidHMRJoinChatRoomWithConfigs(uint64_t roomId, const HMRKvItem *joinProps, int numerOfProperty, HMRCompletion completion)
voidHMRLeaveChatRoom(uint64_t roomId, HMRCompletion completion)
voidHMRChatRoomChangeBasicInfo:(uint64_t roomId, HMRCompletion completion)
voidHMRChatRoomChangeBasicInfo(uint64_t roomId, HMRKvArray *info, HMRCompletion completion)
voidHMRChatRoomFetchMembers(uint64_t roomId, int32_t num, int32_t offset, HMRCompletion completion)
voidHMRChatRoomSetUserInfo(uint64_t roomId, HMRKvArray *infos, HMRCompletion completion)
voidHMRChatRoomFetchOnLineUserInfoList(uint64_t roomId, HMRCompletion completion)
voidHMRAddChatRoomListener(HMRChatRoomListener *listener)
voidHMRRemoveChatRoomListener(HMRChatRoomListener *listener)
voidHMRAddMemberListener(HMRChatRoomMemberListener *listener)
voidHMRRemoveMemberListener(HMRChatRoomMemberListener *listener)
HMRIdentityHMRMakeChatRoomIdentity(uint64_t roomId)
HMRCodeHMRExtractChatRoomId(HMRIdentity identity, uint64_t *roomId)
boolHMRIsChatRoom(HMRIdentity identity)
HMRIdentityHMRMakeChatRoomUser(uint64_t roomId, uint64_t userId)
HMRCodeHMRExtractChatRoomUser(HMRIdentity identity, uint64_t *roomId, uint64_t *userId)
boolHMRIsChatRoomUser(HMRIdentity identity)
  • MessageService

Global FunctionFunction Name
voidHMRSendMessasge(HMRMessage *message, HMRCompletion completion)
voidHMRAddMessageListener(HMRMessageListener *listener)
voidHMRRemoveMessageListener(HMRMessageListener *listener)
HMRMessage *HMRCreateMessage(HMRIdentity receiver, HMRMessageContent content, HMRMessageExtra extra)
voidHMRRetainMessage(HMRMessage *message)
voidHMRReleaseMessage(HMRMessage *message)
HMRMessageExtraHMRMakeMessageExtra(const char *extra, int32_t length)
boolHMRIsMessageFailed(HMRMessage *message)
HMRIdentityHMRGetConversationTarget(HMRMessage *message)

API Details

Core

Core::HMRGetState

Get the SDK current status. See details in HMRState.

Return
  • SDK current status

Core::HMRInit

HMR_API void HMRInit(uint64_t appId);

Initialize a Hummer instance

Notes:

  • Currently, the SDK only supports one Hummer instance and each application only creates one Hummer object.
  • Unless otherwise specified, all API functions of Hummer are asynchronously called, and the API is called in the same thread.
  • Regarding callback for all operations, unless otherwise specified, a HMRResult return of 0 indicates success, while any other value indicates failure. For specific error code meanings, see HMRCode.
Parameter
ParameterDescription
appIdIt is used to identify the specific service. See details in APPID.

Core::HMROpen

HMR_API void HMROpen(uint64_t uid, const char *region, const char *token, HMRCompletion completion);

Log in an SDK

Parameters
ParameterDescription
uidUser ID
regionParameters of a region where a server is should be connected. Consult related SDK developers for details.
tokenA user token is required for service initialization
completionCallback of processing after completion

Core::HMRClose

HMR_API void HMRClose();

Log out an SDK


Core::HMRRefreshToken

HMR_API void HMRRefreshToken(const char *token);

Refresh a user token

Parameters
ParameterDescription
tokenA user token to be refreshed

Core::HMRSetLogger

HMR_API void HMRSetLogger(HMRLogFunction logFunction);

Set SDK log output managed callback

Notes:

  • The service uses this method to set Logger, and the SDK will send log output and printing to the service for processing.
  • The service needs to ensure the reporting of logs so that specific information can be found if and when problems later arise.
Parameters
ParameterDescription
logFunctionCallback of SDK log output. See details in HMRLogFunction.

Core::HMRAddStateListener

HMR_API void HMRAddStateListener(HMRStateListener *listener);

Add an SDK state change listener

Parameters
ParameterDescription
listenerA listener to be added. See details in HMRStateListener.

Core::HMRRemoveStateListener

HMR_API void HMRRemoveStateListener(HMRStateListener *listener);

Remove an SDK state change listener

Parameters
ParameterDescription
listenerA listener to be removed. See details in HMRStateListener.

Core::HMRGetVersion

HMR_API const char *HMRGetVersion();

Get SDK version information

Return
  • SDK version information

ChatRoomService

ChatRoomService::HMRCreateChatRoom

HMR_API void HMRCreateChatRoom(HMRCompletion completion);

Create a chatroom

Notes:

  • The chatroom must be created before it can be used, so you need to create a corresponding chatroom API.
  • After a chatroom is created, the server will return a corresponding chatroom ID used for identifying the chatroom in the future.
  • Chatroom information such as name, description, bulletin, and extension information, should be provided during chatroom creation.
  • Default maximums:
    The number of chatrooms created by one AppId: 100w
    The number of members in one chatroom: 10w
  • A single user’s call frequency is limited to 10 times every 5 seconds.
Parameters
ParameterDescription
completionCallback after chatroom creation: If creation succeeds, the corresponding Chatroom ID will be returned to the service for subsequent chatroom operation; if creation fails, callback will also include the reason.

ChatRoomService::HMRCreateChatRoomWithInfo

HMR_API void HMRCreateChatRoomWithInfo(HMRKvArray *info, HMRCompletion completion);

Create a chatroom and configure chatroom information

Notes:

  • The chatroom must be created before it can be used, so you need to create a corresponding chatroom API.
  • After a chatroom is created, the server will return a corresponding chatroom ID used for identifying the chatroom in the future.
Parameters
ParameterDescription
infoChatroom information objects include name, description, announcement, and extension information. See details in HMRChatRoomBasicInfoType.
completionCallback after chatroom creation: If creation succeeds, the corresponding Chatroom ID will be returned to the service for subsequent chatroom operation; if creation fails, callback will also include the reason.

ChatRoomService::HMRJoinChatRoom

HMR_API void HMRJoinChatRoom(uint64_t roomId, HMRCompletion completion);

Join a chatroom

Notes:

  • You must join a chatroom before you can properly perform operations for that chatroom—for example, sending and receiving public screen or signaling messages.
  • Joining a chatroom follows a logic of “multi-user mutual removal”. For details, consult the background configuration.
  • A single user’s call frequency is limited to 10 times every 5 seconds.
Parameters
ParameterDescription
roomIdChatroom ID
completionCallback after joining a chatroom. The service can perform different operations according to joining results. If joining fails, callback will include the reason for error.

ChatRoomService::HMRJoinChatRoomWithMultiCheck

HMR_API void HMRJoinChatRoomWithMultiCheck(uint64_t roomId, bool isCheckMultiJoin, HMRCompletion completion);

Join a chatroom and check for repeat login of current user

Notes:

  • Currently the chatroom only supports single-end or multi-end access, so the specified access mode can search the background for corresponding configuration. Joining the chatroom via single-end access means that a second user joining the room will remove the first user from the room. If you have joined and now wish to exit the chatroom, call HMRLeaveChatRoom.
  • You must join a chatroom before you can properly perform necessary operations—for example, sending and receiving public screen or signaling messages.
  • A single user’s call frequency is limited to 10 times every 5 seconds.
Parametesr
ParameterDescription
roomIdChatroom ID
isCheckMultiJoinWhether or not to check for repeat login
completionCallback after joining a chatroom. The service can perform different operations according to joining results. If joining fails, callback will include the reason for error.

ChatRoomService::HMRJoinChatRoomWithConfigs

HMR_API void HMRJoinChatRoomWithConfigs(uint64_t roomId, const HMRKvItem *joinProps, int numerOfProperty, HMRCompletion completion);

Join a chatroom and specify extension information

Notes:

  • Currently the chatroom only supports single-end or multi-end access, so the specified access mode can search the background for corresponding configuration. Joining the chatroom via single-end access means that a second user joining the room will remove the first user from the room. If you have joined and now wish to exit the chatroom, call HMRLeaveChatRoom.
  • PYou must join a chatroom before you can properly perform necessary operations—for example, sending and receiving public screen or signaling messages..
  • A single user’s call frequency is limited to 10 times every 5 seconds.
Parameters
ParameterDescription
roomIdChatroom ID
joinPropsAn extension field for service extension. The SDK is only responsible for pass-through.
numerOfPropertyNumber of extension fields
completionCallback after joining a chatroom. The service can perform different operations according to joining results. If joining fails, callback will include the reason for error.

ChatRoomService::HMRLeaveChatRoom

HMR_API void HMRLeaveChatRoom(uint64_t roomId, HMRCompletion completion);

Exit a chatroom

Notes:

  • Once all the necessary logistics for joining the chatroom are processed, you can end interactions with the chatroom by exiting it. Listening to public screen or signaling messages and corresponding callback notifications will also be terminated.
Parameters
ParameterDescription
roomIdChatroom ID
completionCallback after exiting a chatroom. The service can perform different operations according to exiting results. If exiting fails, callback will include the reason for error.

ChatRoomService::HMRChatRoomFetchBasicInfo

HMR_API void HMRChatRoomFetchBasicInfo(uint64_t roomId, HMRCompletion completion);

Get chatroom’s basic profile information

Notes:

  • Getting chatroom information includes chatroom name, description, and bulletin, as well as corresponding extended field information.
  • You can obtain chatroom information without joining the chatroom.
Parameters
ParameterDescription
roomIdChatroom ID
completionAfter callback, the service can perform different operations according to the callback result. Chatroom information is returned through the var parameter of (HMRKvArray*)(var.ptrValue). See details in HMRKvArray.

ChatRoomService::HMRChatRoomChangeBasicInfo

HMR_API void HMRChatRoomChangeBasicInfo(uint64_t roomId, HMRKvArray *info, HMRCompletion completion);

Change chatroom’s basic profile information

Notes:

  • You can change chatroom information for one or more chatrooms according to your needs. Only the key-value pairs to be modified need to be specified in the parameters.
  • A Room Owner or Admin role is required to change chatroom information.
  • A single user’s call frequency is limited to 10 times every 5 seconds.
Parameters
ParameterDescription
roomIdChatroom ID
infoA changed profile value. See HMRChatRoomBasicInfoType for key enumeration values..
completionCallback after change. The service can perform different operations according to the change results.

ChatRoomService::HMRChatRoomFetchMembers

HMR_API void HMRChatRoomFetchMembers(uint64_t roomId, int32_t num, int32_t offset, HMRCompletion completion);

Get a chatroom member list

Notes:

  • In some scenarios, a single chatroom may have many thousands of members; therefore, this SDK provides corresponding paged member lists according to your requirements. Meanwhile, a corresponding member list is sorted according to certain default rules.
  • You can use the API for retrieving the member list even without joining the chatroom.
  • A single user’s call frequency is limited to 10 times every 5 seconds.
Parameters
ParameterDescription
chatRoomChatroom ID
offsetSpecific page (the first page starts from 0)
numSet the number of members returned on each page (recommended no more than 200)
completionAfter callback, the service can perform different operations according to the result obtained, passing the member list through the var parameter of (HMRIdArray*)(var.ptrValue) by using the completion callback method. See details in HMRIdArray.

ChatRoomService::HMRChatRoomSetUserInfo

HMR_API void HMRChatRoomSetUserInfo(uint64_t roomId, HMRKvArray *infos, HMRCompletion completion);

Set own user information

Notes:

  • Maximum capacity:
    set user profiles, the maximum number of supported attributes: 32
    Maximum value for a single user profile: 8K.
  • A single user’s call frequency is limited to 10 times every 5 seconds.
Parameters
ParameterDescription
roomIdChatrooms that a member is in
infosUser information. Support a maximum of 32 users.
completionSet callback for information return, with processing according to error codes

ChatRoomService::HMRChatRoomFetchOnLineUserInfoList

HMR_API void HMRChatRoomFetchOnLineUserInfoList(uint64_t roomId, HMRCompletion completion);

Get a chatroom user information list

Notes:

  • A maximum of 100 member lists can be returned; if over 100 lists are called for, 100 random lists are returned.
Parameters
ParameterDescription
roomIdA chatroom to be searched
completionAfter callback, the service can perform different operations according to the resulting judgment. Chatroom user information is passed through the var parameter of (HMRChatRoomOnLineUserInfoList*)(var.ptrValue). See details in HMRChatRoomOnLineUserInfoList.

ChatRoomService::HMRAddChatRoomListener

HMR_API void HMRAddChatRoomListener(HMRChatRoomListener *listener);

Add a chatroom callback listener

Parameters
ParameterDescription
listenerA listener object. See details in HMRChatRoomListener.

ChatRoomService::HMRRemoveChatRoomListener

HMR_API void HMRRemoveChatRoomListener(HMRChatRoomListener *listener);

Remove a chatroom callback listener

Parameters
ParameterDescription
listenerA listener object. See details in HMRChatRoomListener.

ChatRoomService::HMRAddMemberListener

HMR_API void HMRAddMemberListener(HMRChatRoomMemberListener *listener);

Add a chatroom member callback listener

Parameters
ParameterDescription
listenerA listener object. See details in HMRChatRoomMemberListener.

ChatRoomService::HMRRemoveMemberListener

HMR_API void HMRRemoveMemberListener(HMRChatRoomMemberListener *listener);

Remove a chatroom member callback listener

Parameters
ParameterDescription
listenerA listener object. See details in HMRChatRoomMemberListener.

ChatRoomService::HMRMakeChatRoomIdentity

HMR_API HMRIdentity HMRMakeChatRoomIdentity(uint64_t roomId);

Create an identity object for a chatroom

Parameters
ParameterDescription
roomIdChatroom ID
Return
  • ID is the chatroom's identity object of roomId

ChatRoomService::HMRExtractChatRoomId

HMR_API HMRCode HMRExtractChatRoomId(HMRIdentity identity, uint64_t *roomId);

Extract chatroom ID from the chatroom's identity object

Parameters
ParameterDescription
identityChatroom ID
roomIdResolved chatroom ID
Return
  • Operation result. See details in HMRCode.

ChatRoomService::HMRIsChatRoom

HMR_API bool HMRIsChatRoom(HMRIdentity identity);

Determine whether an identity object represents a chatroom

Parameters
ParameterDescription
identityChatroom ID
Return
  • Chatroom ID or not

ChatRoomService::HMRMakeChatRoomUser

HMR_API HMRIdentity HMRMakeChatRoomUser(uint64_t roomId, uint64_t userId);

Create an identity object for a chatroom user

Parameters
ParameterDescription
roomIdChatroom ID
userIdUser ID
Return
  • ID is the chatroom user's identity object of userId

ChatRoomService::HMRExtractChatRoomUser

HMR_API HMRCode HMRExtractChatRoomUser(HMRIdentity identity, uint64_t *roomId, uint64_t *userId);

Extract chatroom ID value from the chatroom Identity object

Parameters
ParameterDescription
identityChatroom ID
roomIdParsed chatroom ID
userIdParsed user ID
Return
  • Operation result. See details in HMRCode.

ChatRoomService::HMRIsChatRoomUser

HMR_API bool HMRIsChatRoomUser(HMRIdentity identity);

Determine whether an identity object represents a chatroom user

ParameterS
ParameterDescription
identityChatroom ID
Return
  • Determine whether it is a chatroom user ID

MessageService

MessageService::HMRSendMessasge

HMR_API void HMRSendMessasge(HMRMessage *message, HMRCompletion completion);
Notes

A message sending API: supports sending a Public Screen Message (only supports text), Unicast or Broadcast Message.

Notes:

  • This service can compose a message body by itself, filling in corresponding content and sending it out.
  • This API also can resend the message in the case that the message sending fails.
  • A single user’s call frequency limit:
    For sending public screen messages: 10 times/5s
    For sending a custom unicast message: 50 times/5s
    For sending a custom broadcast message: 50 times/5s
  • Maximum capacity:
    For a single unicast message: 2K
    For a single broadcast message: 2K
Parameters
ParameterDescription
messageMessage instance. See details in HMRMessage.
completionCallback of sending operation completion
Callback

There may be multiple stages/statuses in a message sending process, but The completion only conducts final completion callback. Obtain the corresponding callback with HMRMessageListener.

MessageService::HMRAddMessageListener

HMR_API void HMRAddMessageListener(HMRMessageListener *listener);
Notes

Add a message sending/receiving listener

Parameters
ParameterDescription
listenerA listener object to be added. If it has already been added, addListener will be an NOP. See details in HMRMessageListener.

MessageService::HMRRemoveMessageListener

HMR_API void HMRRemoveMessageListener(HMRMessageListener *listener);
Notes

Remove a message sending/receiving listener

Parameters
ParameterDescription
listenerA listener object to be removed. If the listener does not exist, nothing will happen. See details in HMRMessageListener.

MessageService::HMRCreateMessage

HMR_API HMRMessage *HMRCreateMessage(HMRIdentity receiver, HMRMessageContent content, HMRMessageExtra extra);
Notes

Create a message

Parameters
ParameterDescription
receiverMessage receiver. See details in HMRIdentity.
contentMessage content. See details in HMRMessageContent.
extraMessage extension content. See details in HMRMessageExtra.
Return

MessageService::HMRRetainMessage

HMR_API void HMRRetainMessage(HMRMessage *message);
Notes

Retain a message’s reference

Parameters
ParameterDescription
messageMessage instance to be retained. See details in HMRMessage.

MessageService::HMRReleaseMessage

HMR_API void HMRReleaseMessage(HMRMessage *message);
Notes

Release a message’s reference

Parameters
ParameterDescription
messageMessage instance to be retained. See details in HMRMessage.

MessageService::HMRMakeMessageExtra

HMR_API HMRMessageExtra HMRMakeMessageExtra(const char *extra, int32_t length);
Notes

Create a message’s extension information

Parameters
ParameterDescription
extraExtension content
lengthLength of extension content
Return

MessageService::HMRIsMessageFailed

HMR_API bool HMRIsMessageFailed(HMRMessage *message);
Notes

Determine a message’s failure status

Parameters
ParameterDescription
messageMessage instance. See details in HMRMessage.
Return
  • false: fail
  • true: succeed

MessageService::HMRGetConversationTarget

HMR_API HMRIdentity HMRGetConversationTarget(HMRMessage *message);
Notes

Get conversation target corresponding to the message object.

Parameters
ParameterDescription
messageMessage instance. See details in HMRMessage.
Return

Parameter Type

Core

Core::HMRState

enum HMRState

SDK current status

Enumeration ValueDescription
HMRStateUnavailable(-1)An unavailable status. The SDK is in this status while being not initialized.
HMRStateClosed(0)Closed
HMRStateOpening(1)Opening
HMRStateOpened(2)Opened

Core::HMRLogFunction

typedef void(*HMRLogFunction)(const char *message);

Callback method pointer for log output

Parameters
ParameterDescription
messageLog to be outputted

HMRCompletion

struct HMRCompletion {
	// Context object pointer for asynchronous request, which is generally the object pointer that initiates an asynchronous operation
	void *context;

	// ID of request passed in by service when constructing a completion. Uniqueness of the ID is guaranteed by service. Usually used to help service asynchronously request context mapping and recovery
	uint64_t requestId;

	// Function pointer for actually executed callback
	HMROnComplete onComplete;

	// Hummer  Field reserved for internal use, not to be accessed or modified by service
	void *reserved;
};

Asynchronous callback for requested operation

MemberDescription
contextContext object pointer for asynchronous request
requestIdRequest ID automatically loaded upon service creation completion
onCompleteFunction pointer for actually executed callback
reservedInternal reserved field

HMROnComplete

typedef void (*HMROnComplete)(void* context, uint64_t requestId, HMRResult result, HMRVariant var);

Function pointer for asynchronous operation callback

Parameters
ParameterDescription
contextContext object pointer for asynchronous request
requestIdRequest ID automatically loaded upon service creation completion
resultAn asynchronous operation result object. It indicates operation success or failure and provides details on cause in the case of failure.
varA polymorphic simple data structure. Its value varies and has different meanings depending on different asynchronous APIs.

HMRResult

struct HMRResult {
	// Please refer to definitions in the error code table above
	HMRCode code;

	// Explanation of the readable text of the code. Its an ANSI code.
	char msg[256];
};

Operation result

Parameters
ParameterDescription
codeError code
msgExplanation of a code’s readable text, is an ANSI code.

HMRVariant

union HMRVariant {
	void     *ptrValue;
	char     *stringValue;
	uint32_t intValue;
	uint64_t longValue;
};

A polymorphic simple data structure. Its value varies and has different meanings depending on different asynchronous APIs. To determine definition, refer to the corresponding API document.

Parameters
ParameterDescription
ptrValuePointer data
stringValueString data
intValueInteger data
longValueLong integer data

HMRKvItem

struct HMRKvItem {
	const char* key;
	const char* value;
};

Key-value pair information

HMRKvArray

struct HMRKvArray {
	uint32_t len;
	HMRKvItem *items;
};

Key-value pair array

HMRIdArray

struct HMRIdArray
{
	uint32_t len;
	uint64_t* ids;
};

ID array

HMRIdentity

struct HMRIdentity {
	// string is used to store string representations of multiple ID types
	// For example:
	//    User 1234:  user_1234
	//    Chatroom 8876: chatroom_8876
	// Construction and analysis of specific content should always use factory methods of the HMRMakeXXXIdentity series or the HMRExtractXXXId type instead of direct generation. For example: HMRMakeUserIdentity
	char string[128];
};

Hummer internal entity ID

Parameters
ParameterDescription
stringEntity ID

ChatRoomService

HMRChatRoomBasicInfoType

static const char *HMRChatRoomBasicInfoTypeName			= "Name";
static const char *HMRChatRoomBasicInfoTypeDescription	= "Description";
static const char *HMRChatRoomBasicInfoTypeBulletin		= "Bulletin";
static const char *HMRChatRoomBasicInfoTypeAppExtra		= "AppExtra";

A basic chatroom information constant field: mainly used to modify and listen to chatroom information; it can identify which field is or needs to be changed.

Constant ValueDescription
HMRChatRoomBasicInfoTypeNameChatroom name
HMRChatRoomBasicInfoTypeDescriptionChatroom description
HMRChatRoomBasicInfoTypeBulletinChatroom announcement
HMRChatRoomBasicInfoTypeExtentionChatroom extension field (maximum 1K)

HMRChatRoomOnLineUserInfo

struct HMRChatRoomOnLineUserInfo {
	uint64_t uid;
	HMRKvArray *info;
};

Online chatroom user information

Parameters
ParameterDescription
[uid]User ID
[info]User information. See details in HMRKvArray.

HMRChatRoomOnLineUserInfoList

struct HMRChatRoomOnLineUserInfoList {
	uint32_t len;
	HMRChatRoomOnLineUserInfo *users;
};

Online chatroom user information list

Parameters
ParameterDescription
[len]Number of users
[users]User information. See details in HMRChatRoomOnLineUserInfo.

MessageService

MessageService::HMRUUID

struct HMRUUID {
	// Effective length is 36 bytes: 16 * 2 (bytes) + 4 (delimiters) + 1 (terminator), however, considering memory alignment, use 40 bytes
	char string[40];
};

Unique message ID

Parameters
ParameterDescription
stringMessage ID

MessageService::HMRMessageState

const int32_t HMRMessageStateInit       = 0;
const int32_t HRMMessageStateDelivering = 2;
const int32_t HMRMessageStateArchived   = 3;
Constant ValueDescription
HMRMessageStateInit(0)Initialization state, under which messages can be sent.
HRMMessageStateDelivering(2)Sending, a state under which the current message cannot be sent or forwarded again.
HMRMessageStateArchived(3)Archiving state, which indicates that a message has been sent successfully or a message has been received from another end. The message can be sent or forwarded again.

MessageService::HMRMessage

struct HMRMessage {
	// if (state <= HMRMessageStateArchived && state> = 0) 
	// indicates a determined non-failure state, otherwise the state value should indicate sending is failed; the specific value is consistent with the HMRCode error code
	int32_t state;

	// unique message ID, which is usually generated by message sender and helps to de-duplicate and locate a message
	HMRUUID uuid;

	// message timestamp; for chatroom messages, the value is subject to local time. means it should not be used to
	// strict message sorting, otherwise abnormal sorting may be resulted from malicious tampering
	uint64_t timestamp;		

	// message sender ID, which is a User in most cases, or a type customized by service, such as system service official account
	HMRIdentity sender;

	// message receiving target ID; although message is received by the current device, it may be a group relationship message such as ChatRoom
	HMRIdentity receiver;		

	// complete load of message content; during physical processing, load provided by different Content type should be used for
	// dynamic judgment (such as HMRIsTextContent). Direct manual parsing and construction should be avoided unless it is a type expanded by service
	HMRMessageContent content;	

	// every message may carry certain service pass-through information, in order to enable transmission of data such as “avatar/nickname of message sender”
	// Reduce access pressure of business servers
	HMRMessageExtra extra;

	// Hummer  Field reserved for internal use, not to be accessed or modified by service
	void *reserved;
};

Message instances

Notes:

HMRMessage object resource management is implemented by reference counting. Therefore, the service itself manages the release of sent messages.

  • To retain a message received by Hummer, call HMRRetainMessage to keep its reference.
  • When you no longer need to use it, call HMRReleaseMessage to dereference the message.
Parameters
ParameterDescription
stateMessage status. See detail in HMRMessageState.
uuidUnique message ID. See detail in HMRUUID.
timestampMessage timestamp
senderMessage sender ID. See detail in HMRIdentity.
receiverMessage receiver ID. See detail in HMRIdentity.
contentMessage content. See detail in HMRMessageContent.
extraMessage extension content. See details in HMRMessageExtra.
reservedSDK reserved field

MessageService::HMRMessageContent

const int32_t HMRMessageContentSize = 2048;

struct HMRMessageContent {
	char data[HMRMessageContentSize];	// Message content buffer
	uint16_t availableSize;				// Size of valid data in the buffer zone
};

Message content

Notes:

  • Message content structure. Each message’s information is polymorphic—potentially composed of text, signaling, etc.
  • As much as possible, use the creation and resolution methods of the content definition modules (ContentText or ContentSignal) rather than creating or resolving manually.
  • Although data is a char array, it is not necessarily an ANSI string. More often than not, it is a string for storing UTF-8 codes, such as HMRTextContent.
  • Exercise caution when determining the maximum message length to avoid access violation.
Parameters
ParameterDescription
dataContent buffer zone
availableSizeValid data size in the buffer zone

MessageService::HMRMessageExtra

const int32_t HMRMessageExtraSize = 1024; // Size of buffer for data carried by message service

struct HMRMessageExtra {
	// Extra data buffer
	char data[HMRMessageExtraSize];
	// Extra data valid bytes
	uint16_t availableSize;
};

Definition of message extended content

Parameters
ParameterDescription
dataContent buffer zone
availableSizeValid data size in the buffer zone

Was this page helpful?

Helpful Not helpful
Submitted! Your feedback would help us improve the website.
Feedback
Top