feat: 增加请求弹窗和拒绝说明
This commit is contained in:
@@ -102,6 +102,9 @@ class _ControllerHomeState extends State<ControllerHome> {
|
||||
_controller!.onTargetOffline = (message) {
|
||||
_onTargetOffline(message);
|
||||
};
|
||||
_controller!.onConnectionRejected = (message) {
|
||||
_onConnectionRejected(message);
|
||||
};
|
||||
_controller!.onRemoteStream = (renderer) {
|
||||
setState(() => _renderer = renderer);
|
||||
renderer.addListener(_onRendererUpdate);
|
||||
@@ -147,6 +150,20 @@ class _ControllerHomeState extends State<ControllerHome> {
|
||||
setState(() => _connected = false);
|
||||
}
|
||||
|
||||
/// 被控端拒绝连接请求:提示用户并复位到连接设置面板。
|
||||
Future<void> _onConnectionRejected(String message) async {
|
||||
final scaffoldCtx = _scaffoldKey.currentState?.context;
|
||||
if (mounted && scaffoldCtx != null) {
|
||||
ScaffoldMessenger.of(scaffoldCtx).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(message),
|
||||
duration: const Duration(seconds: 3),
|
||||
),
|
||||
);
|
||||
}
|
||||
setState(() => _connected = false);
|
||||
}
|
||||
|
||||
Future<void> _disconnect() async {
|
||||
await _controller?.disconnect();
|
||||
_controller = null;
|
||||
|
||||
Reference in New Issue
Block a user