Function | Function Name |
---|---|
HMRState | state |
void | startWithAppId:appVersion:eventObserver: |
HMRRequestId | loginWithUid:region:token:completion: |
HMRRequestId | logout |
HMRRequestId | refreshToken:completion: |
NSString * | sdkVersion |
BOOL | setLoggerFilePath: |
BOOL | setLogLevel: |
BOOL | setLogCallback: |
BOOL | uploadLogsManually: |
Function | Function Name |
---|---|
instancetype | instance |
HMRRequestId | queryUserOnlineStatus:completion: |
HMRRequestId | sendMessage:withOptions:toUser:completion: |
HMRRequestId | addObserver: |
HMRRequestId | removeObserver: |
+ (HMRState)state;
Get the SDK current status.
+ (void)startWithAppId:(uint64_t)appId
appVersion:(NSString *)appVer
eventObserver:(id<HMREventObserver>)observer;
Initialize Hummer and start listening to Hummer status change.
Notes:
- Currently, the SDK only supports one Hummer instance and each application only creates one Hummer object.
- Unless otherwise specified, all Hummer interface functions are called asynchronously, and the API is called in the same thread.
Parameter | Description |
---|---|
appId | appId used for identifying specific services. See details inAPPID application for details.. |
appVer | Current application version data statistics and fault locating |
observer | Event listener HMREventObserver |
+ (HMRRequestId)loginWithUid:(uint64_t)uid
region:(NSString *)region
token:(NSString *)token
completion:(HMRRequestCompletion)completion;
Log in an SDK.
Notes:
- Execute this method after operation of startWithAppId.
- This method is executed after a user logs in for upper-layer services.
Parameter | Description |
---|---|
uid | User ID, which cannot be 0 |
region | Region parameters for starting user context. For details, contact SDK developers. |
token | A valid user token for SDK authentication |
completion | Callback of processing completion |
+ (HMRRequestId)logout;
Log out an SDK.
Notes:
- This operation must be executed before a user deregisters (logs out of) with a service.
+ (HMRRequestId)refreshToken:(NSString *)token
completion:(HMRRequestCompletion)completion;
Refresh a user token.
Parameter | Description |
---|---|
token | A user token to be refreshed |
completion | Callback of completion. Errors in the callback result should be processed. |
+ (NSString *)sdkVersion;
Get SDK version information.
+ (BOOL)setLoggerFilePath:(NSString *)path;
Set a log saving path. The caller should ensure that the path is valid.
Notes:
- Do not set it as the root directory of a system, such as Documents and Caches!
Parameter | Description |
---|---|
path | Set a log saving path. |
+ (BOOL)setLogLevel:(HMRLogLevel)logLevel;
Set log output level
Parameter | Description |
---|---|
logLevel | Log level, see details in HMRLogLevel |
+ (BOOL)setLogCallback:(HMRLogCallback _Nullable)callback;
Set log output callback.
Parameter | Description |
---|---|
callback | Log output callback, see details in HMRLogCallback |
+ (BOOL)uploadLogsManually:(NSString *)remark;
Report log manually.
Parameter | Description |
---|---|
remark | Remark |
+ (instancetype)instance;
Create and initialize an HMRChatService instance.
- (HMRRequestId)queryUserOnlineStatus:(NSSet<HMRUserId *> *)users
completion:(nullable void (^)(HMRRequestId requestId,
NSDictionary<HMRUserId *, NSNumber *> *onlineUsers,
NSError *error))completion;
Batch search of online users can search the status of a specific user.
Notes:
- 200 users can be searched in batch at maximum.
Parameter | Description |
---|---|
users | Search of list of online users' IDs. See details in HMRUserId. |
completion | Asynchronous callback of this operation |
- (HMRRequestId)sendMessage:(HMRMessage *)message
withOptions:(HMRMessagingOptions *_Nullable)options
toUser:(HMRUserId *)user
completion:(nullable HMRRequestCompletion)completion;
Send P2P signaling messages.
Notes:
- The size of a single message can be 32 KB at most.
Parameter | Description |
---|---|
message | Signaling message to be sent. See details in HMRMessage. |
options | Configuration for sending the message, reserved field. See details in HMRMessagingOptions. |
user | ID of a signaling message receiver. See details in HMRUserId. |
completion | Asynchronous callback of this operation |
- (HMRRequestId)addObserver:(id<HMRPeerServiceObserver>)observer;
Add listeners for signaling messages.
Parameter | Description |
---|---|
observer | Listener object to be added. See details in HMRPeerServiceObserver. |
- (HMRRequestId)removeObserver:(id<HMRPeerServiceObserver>)observer;
Remove listeners for signaling messages.
Parameter | Description |
---|---|
observer | Listener objects to be removed. See details in HMRPeerServiceObserver. |
+ (instancetype)instance;
Create and initialize an HMRChatRoomService instance.
- (HMRRequestId)joinRoom:(HMRRoomId *)roomId
withAppExtras:(nullable NSDictionary<NSString *, NSString *> *)extras
options:(nullable HMRRoomJoiningOptions *)options
completion:(nullable HMRRequestCompletion)completion;
APIs for joining a room.
Parameter | Description |
---|---|
roomId | Room ID specified by operations. See details in HMRRoomId. |
extras | Extension information for joining a room |
options | Optional parameters for joining a room. See details in HMRRoomJoiningOptions. |
completion | Asynchronous callback of this operation |
- (HMRRequestId)leaveRoom:(HMRRoomId *)roomId
completion:(nullable HMRRequestCompletion)completion;
APIs for exiting a room.
Parameter | Description |
---|---|
roomId | Room ID specified by operations. See details in HMRRoomId. |
completion | Asynchronous callback of this operation |
- (HMRRequestId)queryMemberCounts:(NSSet<NSString *> *)roomIds
roomRegion:(NSString *)roomRegion
completion:(nullable void(^)(HMRRequestId requestId,
NSDictionary<HMRRoomId *, NSNumber *> *memberCounts,
NSError *error))completion;
Batch search for number of room members.
Notes:
- Support concurrent search of 20 rooms at maximum.
- Do not support cross-region room search.
Parameter | Description |
---|---|
roomIds | Room ID specified by operations. See details in HMRRoomId.ID. |
roomRegion | Room region. See details in HMRRoomId.region. |
completion | Asynchronous callback of this operation. |
- (HMRRequestId)queryMembers:(HMRRoomId *)roomId
completion:(nullable void(^)(HMRRequestId requestId
, NSArray<HMRUserId *> *members
, NSError *error))completion;
Get a list of members in the specific room.
Notes:
- When over 500 members have joined a room, 500 randomly selected members are returned.
Parameter | Description |
---|---|
roomId | Room ID specified by operations. See details in HMRRoomId. |
completion | Asynchronous callback of this operation |
- (HMRRequestId)setRoomAttributes:(HMRRoomId *)roomId
withAttributes:(NSDictionary <NSString *, NSString *> *)attributes
options:(nullable HMRRoomAttributeOptions *)options
completion:(nullable HMRRequestCompletion)completion;
Set room profiles.
Notes:
- Support full configuration of room profiles for joining and exiting a room.
- Clear room profiles when this room keeps empty for 10 minutes.
- Size of each profile can be up to 8 KB. Each room contains 32 profiles at maximum.
- You are not advised to set the maximum number of profiles and maximum capacity of each profile. Otherwise, you may fail to get profile value when all of them reach peak value.
- When configuring room profiles, you should fill in parameter Key (otherwise, an error is returned), whereas parameter Value can be null.
Parameter | Description |
---|---|
roomId | Room ID specified by operations. See details in HMRRoomId. |
attributes | Profiles |
options | Reserved fields. See details in HMRRoomAttributeOptions. |
completion | Asynchronous callback of this operation |
- (HMRRequestId)addOrUpdateRoomAttributes:(HMRRoomId *)roomId
withAttributes:(NSDictionary <NSString *, NSString *> *)attributes
options:(nullable HMRRoomAttributeOptions *)options
completion:(nullable HMRRequestCompletion)completion;
Add or update profiles of specific rooms.
Notes:
- Update while there are profiles; otherwise, add profiles.
- Clear room profiles when this room keeps empty for 10 minutes.
- Size of each profile can be up to 8 KB. Each room contains 32 profiles at maximum.
- You are not advised to set the maximum number of profiles and maximum capacity of each profile. Otherwise, you may fail to get profile value when all of them reach peak value.
- When configuring room profiles, you should fill in parameter Key (otherwise, an error is returned), whereas parameter Value can be null.
Parameter | Description |
---|---|
roomId | Room ID specified by operations. See details in HMRRoomId. |
attributes | Profiles |
options | Reserved fields. See details in HMRRoomAttributeOptions. |
completion | Asynchronous callback of this operation |
- (HMRRequestId)deleteRoomAttributes:(HMRRoomId *)roomId
byKeys:(NSSet <NSString *> *)keys
options:(nullable HMRRoomAttributeOptions *)options
completion:(nullable HMRRequestCompletion)completion;
Delete specific profiles of specific rooms.
Notes:
- Return success if specific room profiles exist and are deleted.
- Return success if specific room profiles do not exist.
- Return success if some specific room profiles exist.
Parameter | Description |
---|---|
roomId | Room ID specified by operations. See details in HMRRoomId. |
keys | Profile keys |
options | Reserved fields. See details in HMRRoomAttributeOptions. |
completion | Asynchronous callback of this operation |
- (HMRRequestId)clearRoomAttributes:(HMRRoomId *)roomId
withOptions:(nullable HMRRoomAttributeOptions *)options
completion:(nullable HMRRequestCompletion)completion;
Clear profiles of specific rooms.
Notes:
- Clear room profiles when this room keeps empty for 10 minutes.
- Return success if profiles are not configured for a specific room or do not exist.
Parameter | Description |
---|---|
roomId | Room ID specified by operations. See details in HMRRoomId. |
options | Reserved field. See details in HMRRoomAttributeOptions. |
completion | Asynchronous callback of this operation |
- (HMRRequestId)queryRoomAttributes:(HMRRoomId *)roomId
byKeys:(NSSet <NSString *> *)keys
completion:(nullable void (^)(HMRRequestId requestId,
NSDictionary<NSString *, NSString *> *attributes,
NSError *error))completion;
Search specific profiles of specific rooms.
Notes:
- Profile keys: A single key cannot be empty.
- Return success if the searched profile does not exist, but the returned result is empty.
- Only return existing profiles if some room profiles exist.
- Return success if specific room profiles have never been configured, or have been cleared due to timeout but are not configured again. The returned result is empty.
Parameter | Description |
---|---|
roomId | Room ID specified by operations. See details in HMRRoomId. |
keys | Profile keys |
completion | Asynchronous callback of this operation |
- (HMRRequestId)queryRoomAttributes:(HMRRoomId *)roomId
completion:(nullable void (^)(HMRRequestId requestId,
NSDictionary<NSString *, NSString *> *attributes,
NSError *error))completion;
Search all profiles of specific rooms.
Notes:
-Return success if specific room profiles have never been configured, or have been cleared due to timeout but are not configured again. The returned result is empty.
Parameter | Description |
---|---|
roomId | Room ID specified by operations. See details in HMRRoomId. |
completion | Asynchronous callback of this operation |
- (HMRRequestId)setMemberAttributes:(HMRUserId *)member
inRoom:(HMRRoomId *)roomId
withAttributes:(NSDictionary<NSString *, NSString *> *)attributes
options:(nullable HMRMemberAttributeOptions *)options
completion:(nullable HMRRequestCompletion)completion;
Set user profiles in the current room.
Notes:
- You can only set your own profiles at present.
- Size of a user's profile can be up to 8 KB. 32 profiles are supported at maximum.
- You are not advised to set the maximum number of profiles and maximum capacity of each profile. Otherwise, you may fail to get profile value when all the profiles reach peak value.
Parameter | Description |
---|---|
member | Member ID specified by operations. See details in HMRUserId. |
roomId | Room ID specified by operations. See details in HMRRoomId. |
attributes | Profiles |
options | Profile options, reserved fields. See details in HMRMemberAttributeOptions. |
completion | Asynchronous callback of this operation |
- (HMRRequestId)addOrUpdateMemberAttributes:(HMRUserId *)member
inRoom:(HMRRoomId *)roomId
withAttributes:(NSDictionary<NSString *, NSString *> *)attributes
options:(nullable HMRMemberAttributeOptions *)options
completion:(nullable HMRRequestCompletion)completion;
Add or update user profiles in the current room.
Notes:
- Update while there are profiles; otherwise, add profiles.
- You can only set your own profiles at present.
- Size of a user's profile can be up to 8 KB. 32 profiles are supported at maximum.
- You are not advised to set the maximum number of profiles and maximum capacity of each profile. Otherwise, you may fail to get profile value when all the profiles reach peak value.
- Add or update local user profiles in batches.
Parameter | Description |
---|---|
member | User ID. See details in HMRUserId. |
roomId | Room ID specified by operations. See details in HMRRoomId. |
attributes | Profiles |
options | Profile options, reserved fields. See details in HMRMemberAttributeOptions. |
completion | Asynchronous callback of this operation |
- (HMRRequestId)deleteMemberAttributes:(HMRUserId *)member
inRoom:(HMRRoomId *)roomId
byKeys:(NSSet<NSString *> *)keys
options:(nullable HMRMemberAttributeOptions *)options
completion:(nullable HMRRequestCompletion)completion;
Delete specific user profiles in the current room.
Notes:
- You can only set your own profiles at present.
- Return success if some user profiles are deleted while some user profiles do not exist.
Parameter | Description |
---|---|
member | User ID. See details in HMRUserId. |
roomId | Room ID specified by operations. See details in HMRRoomId. |
keys | Profile keys |
options | Profile options, reserved fields. See details in HMRMemberAttributeOptions. |
completion | Asynchronous callback of this operation |
- (HMRRequestId)clearMemberAttributes:(HMRUserId *)member
inRoom:(HMRRoomId *)roomId
options:(nullable HMRMemberAttributeOptions *)options
completion:(nullable HMRRequestCompletion)completion;
Clear all user profiles in the current room.
Notes:
- You can only set your own profiles at present.
- Return success if no profiles are configured for the specific user.
Parameter | Description |
---|---|
member | User ID. See details in HMRUserId. |
roomId | Room ID specified by operations. See details in HMRRoomId. |
options | Profile options, reserved fields. See details in HMRMemberAttributeOptions. |
completion | Asynchronous callback of this operation |
- (HMRRequestId)queryMemberAttributtes:(HMRUserId *)member
inRoom:(HMRRoomId *)roomId
byKeys:(NSSet<NSString *> *)keys
completion:(nullable void (^)(HMRRequestId requestId,
NSDictionary<NSString *, NSString *> *attributtes,
NSError *error))completion;
Search specific user profiles in the current room.
Notes:
- Return success if the searched profile does not exist, but the returned result is empty.
- If some profiles exist, return success only for existing profiles with these profiles being the result.
Parameter | Description |
---|---|
member | User ID. See details in HMRUserId. |
roomId | Room ID specified by operations. See details in HMRRoomId. |
keys | Profile keys |
completion | Asynchronous callback of this operation |
- (HMRRequestId)queryMemberAttributtes:(HMRUserId *)member
inRoom:(HMRRoomId *)roomId
completion:(nullable void (^)(HMRRequestId requestId,
NSDictionary<NSString *, NSString *> *attributtes,
NSError *error))completion;
Search all user profiles in the current room.
Notes:
- Return success if no profiles are configured for a user. The result is empty.
Parameter | Description |
---|---|
member | User ID. See details in HMRUserId. |
roomId | Room ID specified by operations. See details in HMRRoomId. |
completion | Asynchronous callback of this operation |
- (HMRRequestId)sendMessage:(HMRMessage *)message
withOptions:(HMRMessagingOptions *)options
inRoom:(HMRRoomId *)roomId
completion:(nullable HMRRequestCompletion)completion;
Send room messages
Parameter | Description |
---|---|
message | Message to be sent. See details in HMRMessage.. |
options | Configuration for sending the message. See details in HMRMessagingOptions. |
roomId | Room ID. See details in HMRRoomId. |
completion | Asynchronous callback of this operation |
- (HMRRequestId)addMemberObserver:(id <HMRRoomMemberObserver>)observer;
Add listeners for members
Parameter | Description |
---|---|
observer | Listener object to be added. See details in HMRRoomMemberObserver. |
- (HMRRequestId)removeMemberObserver:(id <HMRRoomMemberObserver>)observer;
Remove listeners for members
Parameter | Description |
---|---|
observer | Listener objects to be removed. See details in HMRRoomMemberObserver. |
- (HMRRequestId)addRoomObserver:(id <HMRRoomObserver>)observer;
Add room listeners
Parameter | Description |
---|---|
observer | Listener object to be added. See details in HMRRoomObserver. |
- (HMRRequestId)removeRoomObserver:(id <HMRRoomObserver>)observer;
Remove room listeners
Parameter | Description |
---|---|
observer | Listener objects to be removed. See details in HMRRoomObserver. |
typedef NS_ENUM(NSUInteger, HMRState)
SDK current status
Enumeration Value | Meaning |
---|---|
HMRStateDisconnected(0) | Disconnected |
HMRStateConnecting(1) | Connecting |
HMRStateReconnecting(2) | Reconnecting |
HMRStateConnected(3) | Connected |
Unique request identifier.
typedef NSString * HMRRequestId;
用于表示一个用户的对象
@interface HMRUserId : NSObject <HMRIdentifiable>
HMR_UNAVAILABLE_CONSTRUCTOR;
/**
Create an object by user ID
@param ID User ID
@return Return an object; an HMRMe object is returned if it is the current user
*/
+ (instancetype)userWithID:(UInt64)ID;
/**
Get the user who is currently logged into the SDK
@return The user who is currently logged into the SDK
*/
+ (nullable HMRMe *)getMe;
@end
Log level
typedef NS_ENUM(NSUInteger, HMRLogLevel) {
HMR_LOG_LEVEL_TRACE = 0, // Output logs of all levels
HMR_LOG_LEVEL_DEBUG = 1, // Output logs of DEBUG level
HMR_LOG_LEVEL_INFO = 2, // Output key information and logs of DEBUG level
HMR_LOG_LEVEL_WARNING = 3, // Output warning inforamtion and logs of DEBUG and WARNING level
HMR_LOG_LEVEL_ERROR = 4, // Output errors and logs of DEBUG, WARNING and ERROR level
};
Log callback
typedef void (^HMRLogCallback)(HMRLogLevel level, NSString * _Nullable message);
### HMRPeerService
#### HMRMessage
Signaling message structure of a module.
```objc
@interface HMRMessage : NSObject
/**
Message type for identifying the type of a message, based on which the service can serialize or deserialize content data
*/
@property (nonatomic, copy, readonly) NSString *type;
/**
Serialized message content. the SDK and background are unaware of it. It is used for pass-through.
*/
@property (nonatomic, copy, readonly) NSData *content;
/**
Besides serialized data, the service can pass through specific extended information.
This filed SDK and background are also unaware of and pass through the data.
*/
@property (nonatomic, copy, readonly, nullable) NSDictionary<NSString *, NSString *> *extras;
HMR_UNAVAILABLE_CONSTRUCTOR;
/**
Method for creating a message
@param type Message type
@param content Message type
@param extras Extended information
@return Message instance
*/
+ (instancetype)messageWithType:(NSString *)type
content:(NSData *)content
appExtras:(nullable NSDictionary<NSString *, NSString *> *)extras;
@end
Message configuration information.
@interface HMRMessagingOptions : NSObject <NSCopying>
@end
Room ID. The value can contain only letters and digits selected from [a-zA-Z0-9_-], with 64 bytes at maximum.[]
@interface HMRRoomId : NSObject <NSCopying>
/**
Room ID. The value can contain only letters and digits selected from [a-zA-Z0-9_-], with 64 bytes at maximum.
*/
@property (nonatomic, copy, readonly) NSString *ID;
/**
Region
* If no specific region is displayed, user login region filled in Hummer.login will be used.
I.e.:, specific region prioritizes over the region specified during login.
*/
@property (nonatomic, copy, readonly) NSString *region;
+ (instancetype)roomWithID:(NSString *)ID;
+ (instancetype)roomWithID:(NSString *)ID region:(NSString *)region;
@end
Optional parameters for joining a room.
@interface HMRRoomJoiningOptions : NSObject
@end
Reserved parameters for room profiles.
@interface HMRRoomAttributeOptions : NSObject
@end
Reserved parameters for room user profiles.
@interface HMRMemberAttributeOptions : NSObject
@end