NetworkManager class
网络层统一门面:HTTP + WebSocket + 连通性监视 + 媒体策略。
ImConnStatus 状态机由本类统一推进,并通过
Properties
- connectivity → ConnectivityMonitor
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- http → HttpClient
-
final
- imConnStatus → ImConnStatus
-
no setter
-
imConnStatusStream
→ Stream<
ImConnStatus> -
综合连接状态流(可配合 StreamBuilder / 顶部状态条)
no setter
- isInitialized → bool
-
no setter
- isOnline → bool
-
no setter
- mediaPolicy → MediaPolicy
-
no setter
- networkType → NetworkType
-
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- ws → WsClient
-
final
Methods
-
attachStatusSink(
OnConnListener? sink) → void - 更新 / 更换状态回调接收方
-
clearToken(
) → void -
dispose(
) → Future< void> -
emitImStatus(
ImConnStatus status, {bool force = false}) → void - 统一入口:更新内部状态 → Stream → OnConnListener.onImConnStatusChanged
-
init(
{required String apiAddr, required String wsAddr, required String aesKey, OnConnListener? statusSink, String? acceptLanguage}) → Future< void> -
apiAddrHTTP Base,如http://127.0.0.1:9501wsAddrWS Base,如ws://127.0.0.1:9502statusSink须在连通性回调生效前挂上,否则会漏掉状态事件 -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyConnected(
) → void -
notifyConnecting(
) → void -
notifyDisconnected(
) → void -
notifyReconnect(
) → void -
onAppResumed(
) → Future< void> - App 回前台时刷新连通性并在需要时触发重连
-
setToken(
String token) → void -
syncImStatus(
{bool force = false}) → void -
根据网络 + WS 实时状态推导 ImConnStatus 并下发。
force为 true 时即使状态未变也会回调一次(用于 init / 重新挂载 listener)。 -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- instance → NetworkManager
-
final