简介
此模块定义了跨平台通用的基础类型,为 API 调用提供统一的错误处理和回调机制。
功能特性
回调机制:提供统一的完成回调闭包类型。
数据结构
ExperimentalEventCallback
实验性事件回调,回传 roomID 和 JSON 负载。
ExperimentalAPICallback
实验性 API 调用完成回调,回传错误码、错误信息和引擎返回的 JSON 字符串。
CompletionHandler
完成回调接口。
用于异步操作结果回调的接口,成功时调用 onSuccess,失败时调用 onFailure。
属性
属性 | 类型 | 说明 |
errorCode | int | 错误码。 |
errorMessage | String? | 错误消息描述。 |
isSuccess | bool | 是否成功。 |
使用示例
// CompletionHandler 通过 Future 返回操作结果:// - isSuccess == true:操作成功// - isSuccess == false:通过 errorCode 和 errorMessage 获取错误信息Future<void> handleOperation(Future<CompletionHandler> operation) async {final result = await operation;if (result.isSuccess) {print('操作成功');} else {print('错误码:${result.errorCode},错误信息:${result.errorMessage ?? ''}');}}