Agora RTC Objective-C API Reference Refactor

AgoraRtmClientKit.h
Go to the documentation of this file.
1 //
2 // AgoraRtmClientKit.h
3 // AgoraRtcKit
4 //
5 // Copyright (c) 2022 Agora. All rights reserved.
6 //
7 #import <Foundation/Foundation.h>
11 @class AgoraRtmClientKit;
12 @class AgoraRtmMessageEvent;
13 @class AgoraRtmTopicOption;
14 @class AgoraRtmJoinTopicOption;
15 @class AgoraRtmJoinChannelOption;
16 @class AgoraRtmClientConfig;
17 @class AgoraRtmStreamChannel;
18 @class AgoraRtmTopicInfo;
22 typedef NS_ENUM(NSInteger, AgoraRtmClientErrorCode) {
26 AgoraRtmClientErrTopicAlreadyExist = 10001,
30 AgoraRtmClientErrExceedCreateTopicLimitation = 10002,
34 AgoraRtmClientErrInvalidTopicName = 10003,
38 AgoraRtmClientErrPublishTopicFailed = 10004,
42 AgoraRtmClientErrExceedSubscribeTopicLimitation = 10005,
46 AgoraRtmClientErrExceedUserLimitation = 10006,
50 AgoraRtmClientErrExceedChannelLimitation = 10007,
54 AgoraRtmClientErrAlreadyJoinChannel = 10008,
58 AgoraRtmClientErrNotJoinChannel = 10009,
59 };
60
64 typedef NS_ENUM(NSInteger, AgoraRtmClientConnectionState) {
68 AgoraRtmClientConnectionStateDisconnected = 1,
72 AgoraRtmClientConnectionStateConnecting = 2,
77 AgoraRtmClientConnectionStateConnected = 3,
82 AgoraRtmClientConnectionStateReconnecting = 4,
86 AgoraRtmClientConnectionStateFailed = 5,
87 };
88
93 typedef NS_ENUM(NSInteger, AgoraRtmClientConnectionChangeReason) {
97 AgoraRtmClientConnectionChangedConnecting = 0,
101 AgoraRtmClientConnectionChangedJoinSuccess = 1,
105 AgoraRtmClientConnectionChangedInterrupted = 2,
109 AgoraRtmClientConnectionChangedBannedByServer = 3,
113 AgoraRtmClientConnectionChangedJoinFailed = 4,
117 AgoraRtmClientConnectionChangedLeaveChannel = 5,
121 AgoraRtmClientConnectionChangedInvalidAppId = 6,
125 AgoraRtmClientConnectionChangedInvalidChannelName = 7,
129 AgoraRtmClientConnectionChangedInvalidToken = 8,
133 AgoraRtmClientConnectionChangedTokenExpired = 9,
137 AgoraRtmClientConnectionChangedRejectedByServer = 10,
141 AgoraRtmClientConnectionChangedSettingProxyServer = 11,
145 AgoraRtmClientConnectionChangedRenewToken = 12,
150 AgoraRtmClientConnectionChangedClientIpAddressChanged = 13,
154 AgoraRtmClientConnectionChangedKeepAliveTimeout = 14,
158 AgoraRtmClientConnectionChangedRejoinSuccess = 15,
162 AgoraRtmClientConnectionChangedChangedLost = 16,
166 AgoraRtmClientConnectionChangedEchoTest = 17,
170 AgoraRtmClientConnectionChangedClientIpAddressChangedByUser = 18,
174 AgoraRtmClientConnectionChangedSameUidLogin = 19,
178 AgoraRtmClientConnectionChangedTooManyBroadcasters = 20,
179 };
180
184 typedef NS_ENUM(NSInteger, AgoraRtmChannelType) {
188 AgoraRtmChannelTypeMessage = 0,
192 AgoraRtmChannelTypeStream = 1,
193 };
194
198 typedef NS_ENUM(NSInteger, AgoraRtmPresenceType) {
202 AgoraRtmPresenceTypeRemoteJoinChannel = 0,
206 AgoraRtmPresenceTypeRemoteLeaveChannel = 1,
210 AgoraRtmPresenceTypeRemoteConnectionTimeout = 2,
214 AgoraRtmPresenceTypeRemoteJoinTopic = 3,
218 AgoraRtmPresenceTypeRemoteLeaveTopic = 4,
222 AgoraRtmPresenceTypeSelfJoinChannel = 5,
223 };
224
228 typedef NS_ENUM(NSInteger, AgoraRtmStreamChannelErrorCode) {
232 AgoraRtmStreamChannelErrorOk = 0,
236 AgoraRtmStreamChannelErroExceedLimitation = 1,
240 AgoraRtmStreamChannelErrorUserNotExist = 2,
241 };
242
246 typedef NS_ENUM(NSInteger, AgoraRtmMessageQos) {
250 AgoraRtmMessageQosUnordered = 0,
254 AgoraRtmMessageQosOrdered = 1,
255 };
256
260 __attribute__((visibility("default"))) @interface AgoraRtmJoinTopicOption: NSObject
264 @property (nonatomic, assign) AgoraRtmMessageQos qos;
265
269 @property (nonatomic, nullable) NSData* meta;
270
271 @end
272
276 __attribute__((visibility("default"))) @interface AgoraRtmTopicOption: NSObject
280 @property (nonatomic, copy, nullable) NSArray<NSString *> *users;
281 @end
282
286 __attribute__((visibility("default"))) @interface AgoraRtmJoinChannelOption: NSObject
290 @property (nonatomic, copy, nullable) NSString *token;
291 @end
292
293 __attribute__((visibility("default"))) @interface AgoraRtmMessageEvent: NSObject
297 @property (nonatomic, assign, readonly) AgoraRtmChannelType channelType;
301 @property (nonatomic, copy, nonnull) NSString *channelName;
305 @property (nonatomic, copy, nonnull) NSString *channelTopic;
309 @property (nonatomic, copy, nonnull) NSData *message;
313 @property (nonatomic, copy, nonnull) NSString *publisher;
314 @end
315
316 __attribute__((visibility("default"))) @interface AgoraRtmTopicInfo: NSObject
320 @property (nonatomic, copy, nonnull) NSString *topic;
321
325 @property (nonatomic, copy, nonnull) NSArray<NSString *> *publisherUserIds;
326
330 @property (nonatomic, copy, nonnull) NSArray<NSData *> *publisherMetas;
331 @end
332
333
334 __attribute__((visibility("default"))) @interface AgoraRtmPresenceEvent: NSObject
338 @property (nonatomic, assign, readonly) AgoraRtmChannelType channelType;
342 @property (nonatomic, assign, readonly) AgoraRtmPresenceType type;
346 @property (nonatomic, copy, nonnull) NSString *channelName;
350 @property (nonatomic, copy, nonnull) NSArray<AgoraRtmTopicInfo *> *topicInfos;
354 @property (nonatomic, copy, nonnull) NSString *userId;
355 @end
356
360 __attribute__((visibility("default"))) @interface AgoraRtmClientConfig: NSObject
364 @property (nonatomic, copy, nonnull) NSString *appId;
365
369 @property (nonatomic, copy, nonnull) NSString *userId;
370 @end
371
372 @protocol AgoraRtmClientDelegate <NSObject>
373 @optional
374
380 - (void)rtmKit:(AgoraRtmClientKit * _Nonnull)rtmKit
381 onMessageEvent:(AgoraRtmMessageEvent * _Nonnull)event;
382
400 - (void)rtmKit:(AgoraRtmClientKit * _Nonnull)rtmKit
401 onPresenceEvent:(AgoraRtmPresenceEvent * _Nonnull)event;
402
410 - (void)rtmKit:(AgoraRtmClientKit * _Nonnull)rtmKit
411 onUser:(NSString * _Nonnull)userId
412 joinChannel:(NSString * _Nonnull)channelName
413 result:(AgoraRtmStreamChannelErrorCode)errorCode;
414
422 - (void)rtmKit:(AgoraRtmClientKit * _Nonnull)rtmKit
423 onUser:(NSString * _Nonnull)userId
424 leaveChannel:(NSString * _Nonnull)channelName
425 result:(AgoraRtmStreamChannelErrorCode)errorCode;
426
436 - (void)rtmKit:(AgoraRtmClientKit * _Nonnull)rtmKit
437 onUser:(NSString * _Nonnull)userId
438 joinTopic:(NSString * _Nonnull)topic
439 inChannel:(NSString * _Nonnull)channelName
440 withMeta:(NSData * _Nullable)meta
441 result:(AgoraRtmStreamChannelErrorCode)errorCode;
442
452 - (void)rtmKit:(AgoraRtmClientKit * _Nonnull)rtmKit
453 onUser:(NSString * _Nonnull)userId
454 leaveTopic:(NSString * _Nonnull)topic
455 inChannel:(NSString * _Nonnull)channelName
456 withMeta:(NSData * _Nullable)meta
457 result:(AgoraRtmStreamChannelErrorCode)errorCode;
458
469 - (void)rtmKit:(AgoraRtmClientKit * _Nonnull)rtmKit
470 onUser:(NSString * _Nonnull)userId
471 inTopic:(NSString * _Nonnull)topic
472 inChannel:(NSString * _Nonnull)channelName
473 withSubscribeSuccess:(NSArray<NSString *> * _Nonnull)succeedUsers
474 withSubscribeFailed:(NSArray<NSString *> * _Nonnull)failedUsers
475 result:(AgoraRtmStreamChannelErrorCode)errorCode;
476
487 - (void)rtmKit:(AgoraRtmClientKit * _Nonnull)rtmKit
488 onUser:(NSString * _Nonnull)userId
489 inTopic:(NSString * _Nonnull)topic
490 inChannel:(NSString * _Nonnull)channelName
491 withUnsubscribeSuccess:(NSArray<NSString *> * _Nonnull)succeedUsers
492 withUnsubscribeFailed:(NSArray<NSString *> * _Nonnull)failedUsers
493 result:(AgoraRtmStreamChannelErrorCode)errorCode;
494
502 - (void)rtmKit:(AgoraRtmClientKit * _Nonnull)kit
503 channel:(NSString * _Nonnull)channelName
504 connectionStateChanged:(AgoraRtmClientConnectionState)state
505 result:(AgoraRtmClientConnectionChangeReason)reason;
506
507 @end
508
509
519 __attribute__((visibility("default"))) @interface AgoraRtmClientKit : NSObject
520
521 @property (atomic, weak, nullable) id<AgoraRtmClientDelegate> agoraRtmDelegate;
522
530 - (instancetype _Nullable) initWithConfig:(AgoraRtmClientConfig * _Nonnull)config
531 delegate:(id <AgoraRtmClientDelegate> _Nullable)delegate;
532
538 - (AgoraRtmStreamChannel * _Nullable)createStreamChannel:(NSString * _Nonnull)channelName;
539
540
548 - (int) destroy;
549 @end
550
551 __attribute__((visibility("default"))) @interface AgoraRtmStreamChannel : NSObject
560 - (int)joinWithOption:(AgoraRtmJoinChannelOption * _Nonnull) option;
561
569 - (int)leave;
570
576 - (NSString * _Nonnull) getChannelName;
577
587 - (int) joinTopic:(NSString * _Nonnull)topic withOption:(AgoraRtmJoinTopicOption * _Nullable)option;
588
598 - (int) publishMessage:(NSData * _Nonnull) message
599 inTopic:(NSString * _Nonnull) topic;
600
609 - (int) leaveTopic:(NSString * _Nonnull)topic;
610
619 - (int) subscribeTopic:(NSString * _Nonnull)topic withOption:(AgoraRtmTopicOption * _Nullable)option;
620
629 - (int) unsubscribeTopic:(NSString * _Nonnull)topic withOption:(AgoraRtmTopicOption * _Nullable)option;
630
631 - (int) getSubscribedUserList:(NSMutableArray<NSString *> * _Nonnull)users inTopic:(NSString * _Nonnull)topic;
632
640 - (int) destroy;
641 @end
AgoraRtmClientConnectionChangedInvalidToken
@ AgoraRtmClientConnectionChangedInvalidToken
Definition: AgoraRtmClientKit.h:129
AgoraRtmClientConnectionChangedRejectedByServer
@ AgoraRtmClientConnectionChangedRejectedByServer
Definition: AgoraRtmClientKit.h:137
AgoraRtmChannelTypeStream
@ AgoraRtmChannelTypeStream
Definition: AgoraRtmClientKit.h:192
AgoraRtmJoinTopicOption::meta
NSData * meta
Definition: AgoraRtmClientKit.h:269
AgoraRtmClientConnectionChangedEchoTest
@ AgoraRtmClientConnectionChangedEchoTest
Definition: AgoraRtmClientKit.h:166
AgoraRtmClientConnectionChangedBannedByServer
@ AgoraRtmClientConnectionChangedBannedByServer
Definition: AgoraRtmClientKit.h:109
AgoraRtmPresenceTypeRemoteConnectionTimeout
@ AgoraRtmPresenceTypeRemoteConnectionTimeout
Definition: AgoraRtmClientKit.h:210
-[AgoraRtmStreamChannel getChannelName]
NSString *_Nonnull getChannelName()
AgoraRtmStreamChannelErrorCode
AgoraRtmStreamChannelErrorCode
Definition: AgoraRtmClientKit.h:228
AgoraRtmClientDelegate-p
Definition: AgoraRtmClientKit.h:372
-[AgoraRtmStreamChannel leave]
int leave()
AgoraRtmPresenceType
AgoraRtmPresenceType
Definition: AgoraRtmClientKit.h:198
AgoraRtmClientConnectionChangedTokenExpired
@ AgoraRtmClientConnectionChangedTokenExpired
Definition: AgoraRtmClientKit.h:133
AgoraRtmPresenceTypeSelfJoinChannel
@ AgoraRtmPresenceTypeSelfJoinChannel
Definition: AgoraRtmClientKit.h:222
AgoraRtmJoinChannelOption
Definition: AgoraRtmClientKit.h:287
AgoraRtmClientErrPublishTopicFailed
@ AgoraRtmClientErrPublishTopicFailed
Definition: AgoraRtmClientKit.h:38
AgoraRtmClientConnectionChangedSameUidLogin
@ AgoraRtmClientConnectionChangedSameUidLogin
Definition: AgoraRtmClientKit.h:174
AgoraRtmClientConnectionStateFailed
@ AgoraRtmClientConnectionStateFailed
Definition: AgoraRtmClientKit.h:86
AgoraRtmClientConnectionChangedRejoinSuccess
@ AgoraRtmClientConnectionChangedRejoinSuccess
Definition: AgoraRtmClientKit.h:158
AgoraRtmPresenceTypeRemoteJoinChannel
@ AgoraRtmPresenceTypeRemoteJoinChannel
Definition: AgoraRtmClientKit.h:202
AgoraRtmClientErrNotJoinChannel
@ AgoraRtmClientErrNotJoinChannel
Definition: AgoraRtmClientKit.h:58
AgoraRtmClientConnectionChangedJoinFailed
@ AgoraRtmClientConnectionChangedJoinFailed
Definition: AgoraRtmClientKit.h:113
AgoraRtmClientKit
Definition: AgoraRtmClientKit.h:520
AgoraRtmClientConnectionChangedKeepAliveTimeout
@ AgoraRtmClientConnectionChangedKeepAliveTimeout
Definition: AgoraRtmClientKit.h:154
AgoraRtmClientErrorCode
AgoraRtmClientErrorCode
Definition: AgoraRtmClientKit.h:22
AgoraRtmMessageQos
AgoraRtmMessageQos
Definition: AgoraRtmClientKit.h:246
AgoraRtmJoinTopicOption::qos
AgoraRtmMessageQos qos
Definition: AgoraRtmClientKit.h:264
AgoraRtmPresenceTypeRemoteLeaveChannel
@ AgoraRtmPresenceTypeRemoteLeaveChannel
Definition: AgoraRtmClientKit.h:206
AgoraRtmClientConnectionStateDisconnected
@ AgoraRtmClientConnectionStateDisconnected
Definition: AgoraRtmClientKit.h:68
AgoraRtmChannelTypeMessage
@ AgoraRtmChannelTypeMessage
Definition: AgoraRtmClientKit.h:188
AgoraRtmClientErrInvalidTopicName
@ AgoraRtmClientErrInvalidTopicName
Definition: AgoraRtmClientKit.h:34
AgoraRtmPresenceTypeRemoteJoinTopic
@ AgoraRtmPresenceTypeRemoteJoinTopic
Definition: AgoraRtmClientKit.h:214
AgoraRtmClientConnectionChangedSettingProxyServer
@ AgoraRtmClientConnectionChangedSettingProxyServer
Definition: AgoraRtmClientKit.h:141
AgoraRtmClientConnectionChangedLeaveChannel
@ AgoraRtmClientConnectionChangedLeaveChannel
Definition: AgoraRtmClientKit.h:117
AgoraRtmClientErrExceedCreateTopicLimitation
@ AgoraRtmClientErrExceedCreateTopicLimitation
Definition: AgoraRtmClientKit.h:30
AgoraRtmClientConnectionChangedChangedLost
@ AgoraRtmClientConnectionChangedChangedLost
Definition: AgoraRtmClientKit.h:162
AgoraRtmClientConfig
Definition: AgoraRtmClientKit.h:361
AgoraRtmClientConnectionStateConnecting
@ AgoraRtmClientConnectionStateConnecting
Definition: AgoraRtmClientKit.h:72
AgoraRtmClientErrTopicAlreadyExist
@ AgoraRtmClientErrTopicAlreadyExist
Definition: AgoraRtmClientKit.h:26
AgoraRtmTopicInfo
Definition: AgoraRtmClientKit.h:317
AgoraRtmClientErrExceedUserLimitation
@ AgoraRtmClientErrExceedUserLimitation
Definition: AgoraRtmClientKit.h:46
AgoraRtmClientConnectionStateConnected
@ AgoraRtmClientConnectionStateConnected
Definition: AgoraRtmClientKit.h:77
AgoraRtmClientConnectionChangedTooManyBroadcasters
@ AgoraRtmClientConnectionChangedTooManyBroadcasters
Definition: AgoraRtmClientKit.h:178
AgoraRtmClientConnectionChangedClientIpAddressChangedByUser
@ AgoraRtmClientConnectionChangedClientIpAddressChangedByUser
Definition: AgoraRtmClientKit.h:170
AgoraRtmClientErrExceedChannelLimitation
@ AgoraRtmClientErrExceedChannelLimitation
Definition: AgoraRtmClientKit.h:50
AgoraRtmStreamChannelErrorOk
@ AgoraRtmStreamChannelErrorOk
Definition: AgoraRtmClientKit.h:232
AgoraRtmJoinTopicOption
Definition: AgoraRtmClientKit.h:261
AgoraRtmPresenceTypeRemoteLeaveTopic
@ AgoraRtmPresenceTypeRemoteLeaveTopic
Definition: AgoraRtmClientKit.h:218
AgoraRtmMessageEvent
Definition: AgoraRtmClientKit.h:294
AgoraRtmClientConnectionChangeReason
AgoraRtmClientConnectionChangeReason
Definition: AgoraRtmClientKit.h:93
AgoraRtmMessageQosOrdered
@ AgoraRtmMessageQosOrdered
Definition: AgoraRtmClientKit.h:254
AgoraRtmStreamChannel
Definition: AgoraRtmClientKit.h:552
AgoraRtmClientConnectionChangedJoinSuccess
@ AgoraRtmClientConnectionChangedJoinSuccess
Definition: AgoraRtmClientKit.h:101
AgoraRtmClientConnectionChangedClientIpAddressChanged
@ AgoraRtmClientConnectionChangedClientIpAddressChanged
Definition: AgoraRtmClientKit.h:150
AgoraRtmClientConnectionState
AgoraRtmClientConnectionState
Definition: AgoraRtmClientKit.h:64
AgoraRtmChannelType
AgoraRtmChannelType
Definition: AgoraRtmClientKit.h:184
AgoraRtmClientConnectionChangedRenewToken
@ AgoraRtmClientConnectionChangedRenewToken
Definition: AgoraRtmClientKit.h:145
AgoraRtmClientConnectionStateReconnecting
@ AgoraRtmClientConnectionStateReconnecting
Definition: AgoraRtmClientKit.h:82
AgoraRtmPresenceEvent
Definition: AgoraRtmClientKit.h:335
-[AgoraRtmStreamChannel destroy]
int destroy()
AgoraRtmClientConnectionChangedConnecting
@ AgoraRtmClientConnectionChangedConnecting
Definition: AgoraRtmClientKit.h:97
AgoraRtmStreamChannelErrorUserNotExist
@ AgoraRtmStreamChannelErrorUserNotExist
Definition: AgoraRtmClientKit.h:240
AgoraRtmStreamChannelErroExceedLimitation
@ AgoraRtmStreamChannelErroExceedLimitation
Definition: AgoraRtmClientKit.h:236
AgoraRtmClientErrAlreadyJoinChannel
@ AgoraRtmClientErrAlreadyJoinChannel
Definition: AgoraRtmClientKit.h:54
AgoraRtmClientConnectionChangedInvalidAppId
@ AgoraRtmClientConnectionChangedInvalidAppId
Definition: AgoraRtmClientKit.h:121
AgoraRtmTopicOption
Definition: AgoraRtmClientKit.h:277
AgoraRtmClientConnectionChangedInterrupted
@ AgoraRtmClientConnectionChangedInterrupted
Definition: AgoraRtmClientKit.h:105
AgoraRtmClientConnectionChangedInvalidChannelName
@ AgoraRtmClientConnectionChangedInvalidChannelName
Definition: AgoraRtmClientKit.h:125
AgoraRtmMessageQosUnordered
@ AgoraRtmMessageQosUnordered
Definition: AgoraRtmClientKit.h:250
AgoraRtmClientErrExceedSubscribeTopicLimitation
@ AgoraRtmClientErrExceedSubscribeTopicLimitation
Definition: AgoraRtmClientKit.h:42