EasyClient class

客户端

Inheritance

Constructors

EasyClient({required EasyClientConfig config})

Properties

hashCode int
The hash code for this object.
no setterinherited
httpUrl String
读取http请求的url
no setter
isConnected bool
是否已经建立网络连接
no setter
logTag String
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
threadEnable bool
是否已经建立隔离线程
no setter
websocketUrl String
读取websocket连接的url
no setter

Methods

addListener(String route, void ondata(EasyPacket packet), {bool once = false}) → void
添加指定route的监听器,可用作自由定义事件的管理器
bindUser(String uid, {required String? token}) → void
绑定用户信息。token是数据加解密密钥,为null时,使用EasyClientConfig.pwd进行加解密
connect({void onopen()?, void onclose(int code, String reason)?, void onerror(String error)?, void onretry(int count)?, void onheart(int second, int delay)?, bool now = true}) → void
开始进行网络连接,now为true时立即尝试连接,为false时将会推迟EasyClientConfig.conntick秒连接
destroy() Future<void>
关闭连接销毁实例,调用此函数后,此实例不可进行websocket网络操作,不可重新连接网络。
httpRequest(String route, {Map<String, dynamic>? data, List<List<int>>? fileBytes, MediaType? mediaType, Map<String, String>? headers}) Future<EasyPacket>
发起AES加密通讯的http请求
initThread(Future customHandler(String taskType, dynamic taskData), {bool runErrorsZone = true, bool errorsAreFatal = false}) Future<void>
初始化并发线程,用于客户端高计算量任务,如json解析、加解密操作等
logDebug(List args) → void
inherited
logError(List args) → void
inherited
logFatal(List args) → void
inherited
logInfo(List args) → void
inherited
logTrace(List args) → void
inherited
logWarn(List args) → void
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pauseReconnect() → void
暂停断线自动重连的功能
removeListener(String route, {void ondata(EasyPacket packet)?}) → void
删除指定route的监听器,ondata为null时删除对应route的全部监听器,否则只删除对应ondata函数的监听器
resumeReconnect() → void
恢复断线自动重连的功能
runThreadTask<T>(String taskType, dynamic taskData) Future<T?>
运行一个并发计算任务,taskType为计算任务类型名,taskData计算任务所需数据
toString() String
A string representation of this object.
inherited
triggerEvent(EasyPacket packet) → void
触发EasyPacket.route对应的全部监听器
unbindUser() → void
解绑用户信息
websocketRequest(String route, {Map<String, dynamic>? data, bool waitCompleter = true}) Future<EasyPacket>
发起AES加密通讯的websocket请求,waitCompleter为true时等待服务器响应请求,为false时发送完毕后立即返回

Operators

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

Static Methods

get(String url, {Map<String, String>? headers}) Future<Response>
发起任意的GET请求
post(String url, {Map<String, String>? headers, Object? body, Encoding? encoding}) Future<Response>
发起任意的POST请求