ByteRTCGameRoom class

Inheritance
  • Object
  • NativeClass
  • ByteRTCGameRoom

Constructors

ByteRTCGameRoom([NativeClassOptions? options])

Properties

$resource → NativeResource
no setterinherited
delegate FutureOr<ByteRTCGameRoomDelegate?>
@detail callback
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
ready Future<void>
Whether the instance is initialized
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

destroy() FutureOr<void>
@detail api @author luomingkang @brief 退出并销毁调用 createGameRoom:roomConfig:{@link #ByteRTCEngine#createGameRoom:roomConfig} 所创建的房间实例。
override
enableAudioReceive(NSString userId, BOOL enable) FutureOr<int>
@detail api @author luomingkang @brief 是否订阅指定用户的音频流。 @param userId 用户 ID,最大长度为128字节的非空字符串。支持的字符集范围为:
1. 26个大写字母 A ~ Z
2. 26个小写字母 a ~ z
3. 10个数字 0 ~ 9
4. 下划线"_", at符"@", 减号"-" @param enable 是否订阅音频流:
true:订阅指定用户的音频流。 false:默认设置。不订阅指定用户的音频流。 @return - 0:接口调用成功 - -2:传入的用户 ID 为空字符串。
enableAudioSend(BOOL enable) FutureOr<int>
@detail api @author luomingkang @brief 开始或停止发送音频流。调用此接口不影响音频采集。同游戏房间其他用户会收到相应的回调。 @param enable 是否发送音频流:
- true:发布音频流。 - false:默认设置。停止发布音频流(不会关闭麦克风),即静音。 @return - 0:接口调用成功。 - -3:接口调用失败,未加入房间。 @note 不可与 enableMicrophone:{@link #ByteRTCGameRoom#enableMicrophone} 同时调用。
enableMicrophone(BOOL enable) FutureOr<int>
@detail api @author luomingkang @brief 加入游戏房间后,调用该接口开启或关闭麦克风。同游戏房间其他用户会收到回调 rtcEngine:onAudioDeviceStateChanged:device_type:device_state:device_error:{@link #ByteRTCEngineDelegate#rtcEngine:onAudioDeviceStateChanged:device_type:device_state:device_error}。 @param enable 是否开启麦克风:
- true:开启麦克风,采集并发布音频流。 - false:默认设置。关闭麦克风,停止采集和发布音频流。 @return - 0:接口调用成功。 - -3:接口调用失败。没有加入房间。 @note 不可与 enableAudioSend:{@link #ByteRTCGameRoom#enableAudioSend} 同时调用。
enableSpeakerphone(BOOL enable) FutureOr<int>
@detail api @author luomingkang @brief 加入游戏房间后,开启或关闭扬声器。 @param enable 是否开启声器:
- true:开启扬声器。 - false:默认设置。关闭扬声器。 @return - 0:接口调用成功。 - -3:接口调用失败。没有加入房间。
getRangeAudio() FutureOr<ByteRTCRangeAudio>
@detail api @author luomingkang @brief 获取游戏房间的范围语音接口实例。 @return 方法调用结果:
- ByteRTCRangeAudio:成功,返回一个 ByteRTCRangeAudio{@link #ByteRTCRangeAudio} 实例。 - NULL:失败,当前 SDK 不支持范围语音功能。 @note 首次调用该方法须在创建房间后、加入房间前。范围语音相关 API 和调用时序详见范围语音
joinRoom(NSString token, ByteRTCUserInfo userInfo) FutureOr<int>
@detail api @author luomingkang @brief 加入游戏房间。
调用 createGameRoom:roomConfig:{@link #ByteRTCEngine#createGameRoom:roomConfig} 创建房间后,调用此方法加入房间,同房间内其他用户进行音频通话。 @param token 动态密钥,用于对登录用户进行鉴权验证。
进入房间需要携带 Token。测试时可使用控制台生成临时 Token,正式上线需要使用密钥 SDK 在您的服务端生成并下发 Token。Token 有效期及生成方式参看使用 Token 完成鉴权
- 使用不同 App ID 的 App 是不能互通的。 - 请务必保证生成 Token 使用的 App ID 和创建引擎时使用的 App ID 相同,否则会导致加入房间失败。 @param userInfo 用户信息,参看 ByteRTCUserInfo{@link #ByteRTCUserInfo}。 @return - 0: 成功。触发以下回调: - 本端收到房间状态通知 rtcRoom:onRoomStateChanged:withUid:state:extraInfo:{@link #ByteRTCGameRoomDelegate#rtcRoom:onRoomStateChanged:withUid:state:extraInfo} 回调。 - 如果本端用户为可见用户,房间内其他用户收到 rtcRoom:onUserJoined:{@link #ByteRTCGameRoomDelegate#rtcRoom:onUserJoined} 回调通知。 - -1:room_id / user_info.uid 包含了无效的参数。 - -2:已经在房间内。接口调用成功后,只要收到返回值为 0 ,且未调用 leaveRoom:{@link #ByteRTCGameRoom#leaveRoom} 成功,则再次调用进房接口时,无论填写的房间 ID 和用户 ID 是否重复,均触发此返回值。 调用失败时,具体失败原因会通过 rtcRoom:onRoomStateChanged:withUid:state:extraInfo:{@link #ByteRTCGameRoomDelegate#rtcRoom:onRoomStateChanged:withUid:state:extraInfo} 回调告知。 @note - 同一个 App ID 的同一个房间内,每个用户的用户 ID 必须是唯一的。如果两个用户的用户 ID 相同,则后进房的用户会将先进房的用户踢出房间,并且先进房的用户会收到 rtcRoom:onRoomStateChanged:withUid:state:extraInfo:{@link #ByteRTCGameRoomDelegate#rtcRoom:onRoomStateChanged:withUid:state:extraInfo} 回调通知,错误类型详见 ByteRTCErrorCode{@link #ByteRTCErrorCode} 中的 ByteRTCErrorCodeDuplicateLogin。 - 用户加入房间成功后,在本地网络状况不佳的情况下,SDK 可能会与服务器失去连接,并触发 rtcEngine:onConnectionStateChanged:{@link #ByteRTCEngineDelegate#rtcEngine:onConnectionStateChanged} 回调。此时 SDK 会自动重试,直到成功重连。重连成功后,本地会收到 rtcRoom:onRoomStateChanged:withUid:state:extraInfo:{@link #ByteRTCGameRoomDelegate#rtcRoom:onRoomStateChanged:withUid:state:extraInfo} 回调通知。
leaveRoom() FutureOr<int>
@detail api @author luomingkang @brief 离开游戏房间。
调用此方法结束通话过程,并释放所有通话相关的资源。 @return - 0: 调用成功。如果用户是房间内可见用户,触发以下回调: - 远端用户收到 rtcRoom:onUserLeave:reason:{@link #ByteRTCGameRoomDelegate#rtcRoom:onUserLeave:reason} 回调通知。 - 正在发布的流会被取消发布。远端用户收到 rtcRoom:onVideoPublishStateChanged:info:state:reason:{@link #ByteRTCGameRoomDelegate#rtcRoom:onVideoPublishStateChanged:info:state:reason}、rtcRoom:onAudioPublishStateChanged:info:state:reason:{@link #ByteRTCGameRoomDelegate#rtcRoom:onAudioPublishStateChanged:info:state:reason}、rtcRoom:onScreenVideoPublishStateChanged:userId:state:reason:{@link #ByteRTCGameRoomDelegate#rtcRoom:onScreenVideoPublishStateChanged:userId:state:reason} 和/或 rtcRoom:onScreenAudioPublishStateChanged:userId:state:reason:{@link #ByteRTCGameRoomDelegate#rtcRoom:onScreenAudioPublishStateChanged:userId:state:reason} 回调通知。 - < 0: 调用失败,参看 ByteRTCReturnStatus{@link #ByteRTCReturnStatus} 获得更多错误说明。 @note - 加入房间后,必须调用此方法结束通话,否则无法开始下一次通话。 - 此方法是异步操作,调用返回时并没有真正退出房间。真正退出房间后,本地会收到 rtcRoom:onRoomStateChangedWithReason:withUid:state:reason:{@link #ByteRTCGameRoomDelegate#rtcRoom:onRoomStateChangedWithReason:withUid:state:reason} 回调通知。你必须在收到 rtcRoom:onRoomStateChangedWithReason:withUid:state:reason:{@link #ByteRTCGameRoomDelegate#rtcRoom:onRoomStateChangedWithReason:withUid:state:reason} 回调后,再销毁房间或引擎,或调用 joinRoom:userInfo:{@link #ByteRTCGameRoom#joinRoom:userInfo} 再次加入房间。
nativeCall<T>(String method, [List? args, NativeMethodMeta? meta]) Future<T>
Call instance method
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
sendInstanceGet<T>(String property) Future<T>
Get instance property
inherited
sendInstancePropertiesGet(dynamic nativeClass) Future<Map<String, dynamic>>
Get instance properties
inherited
sendInstanceSet(String property, dynamic value) Future<void>
Set instance property
inherited
setRemoteRoomAudioPlaybackVolume(NSInteger volume) FutureOr<int>
@detail api @author zhangcaining @brief 调节某个游戏房间内所有远端用户的音频播放音量。 @param volume 音频播放音量值和原始音量的比值,范围是 0, 400,单位为 %,自带溢出保护。为保证更好的通话质量,建议将 volume 值设为 0,100
- 0: 静音 - 100: 原始音量,默认值 - 400: 最大可为原始音量的 4 倍(自带溢出保护) @return - 0: 调用成功。 - < 0 : 调用失败。查看 ByteRTCReturnStatus{@link #ByteRTCReturnStatus} 获得更多错误说明 @note 假设某远端用户 A 始终在被调节的目标用户范围内,
- 该方法与 setRemoteAudioPlaybackVolume:volume:{@link #ByteRTCEngine#setRemoteAudioPlaybackVolume:volume} 互斥,最新调用的任一方法设置的音量将覆盖此前已设置的音量,效果不叠加; - 当该方法与 setPlaybackVolume:{@link #ByteRTCEngine#setPlaybackVolume} 方法共同使用时,本地收听用户 A 的音量将为两次设置的音量效果的叠加。
setRTCGameRoomDelegate(id<ByteRTCGameRoomDelegate> roomDelegate) FutureOr<int>
@detail api @author luomingkang @brief 通过设置 ByteRTCGameRoom{@link #ByteRTCGameRoom} 对象的事件句柄,监听此对象对应的回调事件。 @param roomDelegate 参见 ByteRTCRoomDelegate{@link #ByteRTCRoomDelegate}。 @return - 0: 调用成功。 - < 0 : 调用失败。查看 ByteRTCReturnStatus{@link #ByteRTCReturnStatus} 获得更多错误说明
toString() String
A string representation of this object.
inherited
updateResource(NativeResource resource) → void
inherited
updateToken(NSString token) FutureOr<int>
@detail api @author luomingkang @brief 更新游戏房间 Token。
收到 onTokenWillExpire:{@link #ByteRTCGameRoomDelegate#onTokenWillExpire},onPublishPrivilegeTokenWillExpire:{@link #ByteRTCGameRoomDelegate#onPublishPrivilegeTokenWillExpire},或 onSubscribePrivilegeTokenWillExpire:{@link #ByteRTCGameRoomDelegate#onSubscribePrivilegeTokenWillExpire} 时,你必须重新获取 Token,并调用此方法更新 Token,以保证通话的正常进行。 @param token 重新获取的有效 Token。
如果 Token 无效,你会收到 rtcRoom:onRoomStateChangedWithReason:withUid:state:reason:{@link #ByteRTCGameRoomDelegate#rtcRoom:onRoomStateChangedWithReason:withUid:state:reason} ,错误码是 -1010。 @return - 0:成功; - !0:失败。 @note 请勿同时调用 updateToken:{@link #ByteRTCGameRoom#updateToken} 和 joinRoom:userInfo:{@link #ByteRTCGameRoom#joinRoom:userInfo} 重新加入房间。

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Properties

codegen_$namespace → dynamic
no setter