dio加入自定义contentType web服务器加入 url token参数
This commit is contained in:
@@ -22,7 +22,7 @@ class WebSocket {
|
||||
//判断是否启用自动重连
|
||||
if (_config.reConnect && _reConnect) {
|
||||
//2秒后重连
|
||||
Future.delayed(Duration(seconds: 2), () {
|
||||
Future.delayed(Duration(seconds: _config.reConnectTime), () {
|
||||
connect();
|
||||
});
|
||||
}
|
||||
@@ -56,6 +56,9 @@ class WebSocket {
|
||||
_timer = null;
|
||||
//尝试重连
|
||||
_channel = null;
|
||||
if (_config.onClose != null) {
|
||||
_config.onClose!();
|
||||
}
|
||||
reConnect();
|
||||
});
|
||||
//定期发送心跳包
|
||||
@@ -77,9 +80,14 @@ class WebSocket {
|
||||
class WebSocketConfig {
|
||||
String host;
|
||||
bool reConnect;
|
||||
int reConnectTime;
|
||||
void Function(String) messgae;
|
||||
void Function()? onOpen;
|
||||
void Function()? onClose;
|
||||
|
||||
WebSocketConfig(this.host, this.messgae,
|
||||
{this.reConnect = true, this.onOpen});
|
||||
{this.reConnect = true,
|
||||
this.onOpen,
|
||||
this.onClose,
|
||||
this.reConnectTime = 2});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user