dio加入自定义contentType web服务器加入 url token参数

This commit is contained in:
2026-03-11 11:58:51 +08:00
parent 9e3a7d5721
commit a8e4ad5a20
3 changed files with 26 additions and 6 deletions

View File

@@ -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});
}