From: Changgyu Choi Date: Fri, 14 Apr 2023 01:58:37 +0000 (+0900) Subject: [cion] Add a missing disconnect on dart client X-Git-Tag: accepted/tizen/unified/20230420.153149~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c5d9cc7cbc8f2000548a89b72db30994810bc784;p=platform%2Fcore%2Fappfw%2Ftidl.git [cion] Add a missing disconnect on dart client Change-Id: I4a455c94f8fbb69ce617f22313a060d4bfbdb546 Signed-off-by: Changgyu Choi --- diff --git a/idlc/gen_cion/dart_cion_proxy_gen_cb.h b/idlc/gen_cion/dart_cion_proxy_gen_cb.h index 6f948562..8fb37a7b 100644 --- a/idlc/gen_cion/dart_cion_proxy_gen_cb.h +++ b/idlc/gen_cion/dart_cion_proxy_gen_cb.h @@ -49,15 +49,18 @@ class _ extends _Delegate { */ constexpr const char CB_INTERFACE_BASE[] = R"__dart_cb( +typedef OnDisconnected = Future Function(PeerInfo); + /// [] class for Cion. class { /// Constructor for this class. - (this.serverDisplayName) : _client = Client(''); + (this.serverDisplayName, {SecurityInfo? security}) : _client = Client('', security: security); final List<_Delegate> _delegates = <_Delegate>[]; Future _onDisconnectedEvent(PeerInfo peer) async { _isConnected = false; + _onDisconnected?.call(peer); } Future _onDiscoveredEvent(PeerInfo peer) async { @@ -106,7 +109,7 @@ class { } /// Connects with the server. - Future connect() async { + Future connect({required OnDisconnected onDisconnected}) async { if (_isConnected) { return true; } @@ -115,11 +118,21 @@ class { throw StateError('Already try to connect'); } + _onDisconnected = onDisconnected; await _client.tryDiscovery(onDiscovered: _onDiscoveredEvent); _connectCompleter = Completer(); return _connectCompleter!.future; } + /// Disconnects with the server. + void disconnect() { + if (!_isConnected) { + return; + } + + _client.disconnect(); + } + /// Disposes of registered delegate interface. void disposeCallback(Function callback) { _delegates @@ -131,6 +144,7 @@ class { final Client _client; final String serverDisplayName; bool _isConnected = false; + OnDisconnected? _onDisconnected; Completer? _connectCompleter; } )__dart_cb";