12345678910111213141516171819202122232425262728293031323334 |
- import 'package:fis_common/event/event_type.dart';
- enum ConnectionStatus {
- connecting,
- connected,
- connectFailed,
- connectedClosed,
- }
- abstract class IConnection {
- /// 连接状态
- ConnectionStatus get status;
- /// 是否已连接
- bool get isConnected;
- /// 是否保活
- bool get isKeepAlive;
- /// 接收消息事件
- late FEventHandler<dynamic> messageReceived;
- /// 发送异常事件
- FEventHandler<Exception>? exceptionOccurred;
- /// 状态变更事件
- FEventHandler<ConnectionStatus>? statusChanged;
- /// 连接
- Future<bool> connect();
- /// 关闭连接
- Future<bool> close();
- }
|