新增 token自动提交
This commit is contained in:
@@ -33,6 +33,11 @@ class WebSocket {
|
||||
final channel = WebSocketChannel.connect(wsUrl);
|
||||
try {
|
||||
await channel.ready;
|
||||
Future.delayed(Duration(seconds: 2), () {
|
||||
if (_config.onOpen != null) {
|
||||
_config.onOpen!();
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
print(e);
|
||||
//连接失败
|
||||
@@ -73,6 +78,8 @@ class WebSocketConfig {
|
||||
String host;
|
||||
bool reConnect;
|
||||
void Function(String) messgae;
|
||||
void Function()? onOpen;
|
||||
|
||||
WebSocketConfig(this.host, this.messgae, {this.reConnect = true});
|
||||
WebSocketConfig(this.host, this.messgae,
|
||||
{this.reConnect = true, this.onOpen});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user