Core class
客户端核心:组装会话管理、传输层、本地存储和同步引擎(《4.实现与测试》第 4 节)。 Flutter SDK 中只有主 isolate 创建它;它持有长连接、执行同步、写本地数据库、负责续期,与 Web SDK 的主标签页相同。
Constructors
- Core(ResolvedOptions opts, DRPlatform platform, {required String deviceId, required DeviceInfo deviceInfo})
Properties
- auth ↔ AuthManager
-
latefinal
-
badgeFallback
↔ Future<
void> Function(int badge)? -
没有长连接时上报角标(推送包设置:PUT /client/v1/push/device/badge)。
getter/setter pair
- badgeProvider ↔ int? Function()?
-
切到后台时上报的角标(由客户端按选项设置)。
getter/setter pair
- conn ↔ ConnectionManager
-
latefinal
- destroyed → bool
-
no setter
- deviceId → String
-
final
- deviceInfo → DeviceInfo
-
final
-
events
→ Stream<
({String name, Object? payload})> -
内部事件(事件名与 Web SDK 相同,由客户端转换为 Dart 的事件类)。
no setter
-
foregroundHooks
→ List<
void Function()> -
回到前台时的额外工作(推送包检查通知权限、来电包查询正在进行的通话等)。
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- http ↔ ApiClient
-
latefinal
- kv ↔ KvStore
-
latefinal
- log ↔ Logger
-
latefinal
-
loginSeed
→ Map<
String, Object?> ? -
no setter
- me → String?
-
no setter
-
modules
→ List<
ClientModule> -
final
- opts → ResolvedOptions
-
final
- platform → DRPlatform
-
final
-
recentFailures
→ List<
FailureRecord> -
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- serverTimeOffsetMs ↔ int
-
getter/setter pair
- sessionStore ↔ SessionStore
-
latefinal
- signedIn → bool
-
no setter
- storageFullHandler ↔ void Function()?
-
磁盘空间不足时的处理(客户端设置为本地数据的清理)。
getter/setter pair
- store ↔ LocalStore
-
latefinal
- sync ↔ SyncEngine
-
latefinal
Methods
-
authData(
bool foreground) → Future< ({Map< String, Object?> data, String sessionId})?> - 认证帧的内容;没有会话时为 null。令牌已过期的先续期。
-
call<
T> (String method, [List< Object?> args = const []]) → Future<T> -
currentSessionId(
) → String? -
destroy(
) → Future< void> - 关闭长连接、关闭数据库;不退出登录(测试用:客户端与进程同生命周期)。
-
diagnostics(
) → Map< String, Object?> -
endSession(
DRException err) → void -
handle(
String method, CallHandler fn) → void - 注册一个方法(后台客户端经端口转发的调用也按名称找到它,《3.接口设计》第 8 节)。
-
hasHandler(
String method) → bool -
moduleLog(
String name) → ModuleLogger -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onCompleted(
List< SyncModule> modules, SyncTrigger trigger) → void -
onConnected(
void handler(Map< String, Object?> reply)) → void - 长连接认证成功(认证回复)时调用,先于同步。
-
onDirect(
String event, void handler(EventFrame frame)) → void - 不经暂存直接处理的通知(正在输入、在线状态、聊天室等)。
-
onDisconnected(
) → void -
onEvent(
EventFrame frame) → void -
onFailed(
SyncModule module, DRException error) → void -
onProgress(
List< SyncModule> ? pending) → void -
onReady(
Map< String, Object?> reply) → void -
onRebuilt(
String reason) → void - 数据库的结构版本比本 SDK 新(App 降级):已删除重建,按新设备同步(《1.本地存储》第 8 节)。
-
onResumed(
) → void -
onSignedIn(
String username, String sessionId, bool fresh, Map< String, Object?> ? login) → Future<void> -
onSignedOut(
String username, DataDeletion deletion, bool ended) → Future< void> -
onStateChange(
DRConnectionState state) → void -
onStateChanged(
AuthState state) → void -
onStorageFull(
) → void - 写入时磁盘已满(《1.本地存储》第 6 节)。
-
onSuspended(
) → void -
onTokensChanged(
bool passwordChanged) → void -
onUnrouted(
EventFrame frame) → void -
publish(
String name, Object? payload) → void - 向 App 发出事件(写入本地存储之后调用)。
-
register(
ClientModule module) → void -
reload(
) → Future< void> - 从本地存储重新加载,发出 storage.reset(reloaded)。
-
renew(
) → Future< bool> -
request<
T> (ApiRequest req) → Future< T> -
requestIdempotent<
T> (ApiRequest req) → Future< T> - 本身幂等的请求:暂时故障退避重试最多 3 次,限流 ≤60 秒的等待后重试。
-
requireSignedIn(
) → void - 已登录:本地存储已打开,或者已有会话、正在打开。
-
serverNow(
) → int -
start(
) → Future< void> - 创建客户端后:读取安全存储、处理待删除的数据库、读取本地的登录状态,监听前后台和网络。
-
suspend(
DRException err, int? retryAfterSeconds) → void -
toString(
) → String -
A string representation of this object.
inherited
-
upgradeRequired(
String? minVersion) → void
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited