فهرست منبع

modify JsonRpcNotificationListener

melon.yin 2 سال پیش
والد
کامیت
f15c059224
2فایلهای تغییر یافته به همراه4 افزوده شده و 5 حذف شده
  1. 3 5
      lib/listener/listener.dart
  2. 1 0
      pubspec.yaml

+ 3 - 5
lib/listener/listener.dart

@@ -58,13 +58,11 @@ class JsonRpcNotificationListener {
 
   /// Add notification-handler.
   ///
-  /// [type] The type of message for targeting handlers.
-  ///
   /// [handler] A notification-handler instance extends class [JsonRpcNotificationHandlerBase].
   void addHandler<T extends JsonRpcNotificationHandlerBase>(
-    NotificationTypeEnum type,
     T handler,
   ) {
+    final type = handler.type;
     if (!_handlersMap.containsKey(type)) {
       _handlersMap[type] = {};
     }
@@ -83,8 +81,8 @@ class JsonRpcNotificationListener {
     set.removeWhere((e) => e is T);
   }
 
-  /// Dispose connection & other resources.
-  void dispose() {
+  /// Close and dispose connection/other resources.
+  void close() {
     if (channel != null) {
       if (channel!.closeCode != null) {
         channel!.sink.close(wsStatus.normalClosure);

+ 1 - 0
pubspec.yaml

@@ -18,6 +18,7 @@ dependencies:
       git:
         url: http://git.ius.plus:88/Project-Wing/fis_lib_common.git
         ref: ^1.0.0
+  web_socket_channel: 2.2.0
 
 dev_dependencies:
   flutter_test: