From 32ec432bd84d0246d2c933bd4dee07a7556586a9 Mon Sep 17 00:00:00 2001 From: Djihanegh Date: Wed, 29 Sep 2021 10:21:42 +0200 Subject: [PATCH 1/5] fixing singleton problem --- example/pubspec.lock | 6 +++--- lib/src/pusher/pusher_client.dart | 10 +++++----- pubspec.lock | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/example/pubspec.lock b/example/pubspec.lock index ef532a2..f7f5f8e 100644 --- a/example/pubspec.lock +++ b/example/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0" + version: "2.6.1" boolean_selector: dependency: transitive description: @@ -106,7 +106,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" stack_trace: dependency: transitive description: @@ -141,7 +141,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19" + version: "0.3.0" typed_data: dependency: transitive description: diff --git a/lib/src/pusher/pusher_client.dart b/lib/src/pusher/pusher_client.dart index 4394608..a8c3ba1 100644 --- a/lib/src/pusher/pusher_client.dart +++ b/lib/src/pusher/pusher_client.dart @@ -26,20 +26,20 @@ class PusherClient extends StreamHandler { void Function(ConnectionError?)? _onConnectionError; String? _socketId; - PusherClient._( + /*PusherClient._( String appKey, PusherOptions options, { bool enableLogging = true, bool autoConnect = true, - }); + });*/ /// Creates a [PusherClient] -- returns the instance if it's already be called. - factory PusherClient( + PusherClient( String appKey, PusherOptions options, { bool enableLogging = true, bool autoConnect = true, - }) { + }); /*{ _singleton ??= PusherClient._( appKey, options, @@ -54,7 +54,7 @@ class PusherClient extends StreamHandler { if (autoConnect) _singleton!.connect(); return _singleton!; - } + }*/ Future _init(String appKey, PusherOptions options, InitArgs initArgs) async { registerListener(classId, _eventHandler); diff --git a/pubspec.lock b/pubspec.lock index 96b4a33..4ed2c66 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -7,7 +7,7 @@ packages: name: async url: "https://pub.dartlang.org" source: hosted - version: "2.5.0" + version: "2.6.1" boolean_selector: dependency: transitive description: @@ -92,7 +92,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" stack_trace: dependency: transitive description: @@ -127,7 +127,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.2.19" + version: "0.3.0" typed_data: dependency: transitive description: From 1aa7a9c1963d19222c00e5cf587fdf2436818279 Mon Sep 17 00:00:00 2001 From: Djihanegh Date: Wed, 29 Sep 2021 11:12:26 +0200 Subject: [PATCH 2/5] fix bugs --- lib/src/pusher/pusher_client.dart | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/src/pusher/pusher_client.dart b/lib/src/pusher/pusher_client.dart index a8c3ba1..ae86d5b 100644 --- a/lib/src/pusher/pusher_client.dart +++ b/lib/src/pusher/pusher_client.dart @@ -26,20 +26,23 @@ class PusherClient extends StreamHandler { void Function(ConnectionError?)? _onConnectionError; String? _socketId; - /*PusherClient._( + PusherClient._( String appKey, PusherOptions options, { bool enableLogging = true, bool autoConnect = true, - });*/ + }); + + //String? appKey; + //PusherOptions? options; /// Creates a [PusherClient] -- returns the instance if it's already be called. - PusherClient( + PusherClient( String appKey, PusherOptions options, { bool enableLogging = true, bool autoConnect = true, - }); /*{ + }) { _singleton ??= PusherClient._( appKey, options, @@ -53,8 +56,12 @@ class PusherClient extends StreamHandler { if (autoConnect) _singleton!.connect(); - return _singleton!; - }*/ + // return _singleton!; + } + + //String getAppKey() => appKey!; + + // PusherOptions getOptions() => options!; Future _init(String appKey, PusherOptions options, InitArgs initArgs) async { registerListener(classId, _eventHandler); From df63fd35cb5948bde4bbde585451239392c3c640 Mon Sep 17 00:00:00 2001 From: Djihanegh Date: Wed, 29 Sep 2021 11:23:06 +0200 Subject: [PATCH 3/5] fixing some bugs --- lib/src/pusher/pusher_client.dart | 18 +++++++++++++++--- pubspec.yaml | 7 ------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/lib/src/pusher/pusher_client.dart b/lib/src/pusher/pusher_client.dart index ae86d5b..1e8054e 100644 --- a/lib/src/pusher/pusher_client.dart +++ b/lib/src/pusher/pusher_client.dart @@ -26,13 +26,25 @@ class PusherClient extends StreamHandler { void Function(ConnectionError?)? _onConnectionError; String? _socketId; - PusherClient._( + /* PusherClient._( String appKey, PusherOptions options, { bool enableLogging = true, bool autoConnect = true, }); + plugin: + platforms: + android: + package: com.github.chinloyal.pusher_client + pluginClass: PusherClientPlugin + ios: + pluginClass: PusherClientPlugin + + + + */ + //String? appKey; //PusherOptions? options; @@ -42,7 +54,7 @@ class PusherClient extends StreamHandler { PusherOptions options, { bool enableLogging = true, bool autoConnect = true, - }) { + }); /*{ _singleton ??= PusherClient._( appKey, options, @@ -57,7 +69,7 @@ class PusherClient extends StreamHandler { if (autoConnect) _singleton!.connect(); // return _singleton!; - } + } */ //String getAppKey() => appKey!; diff --git a/pubspec.yaml b/pubspec.yaml index 52bae02..721e1c2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -20,10 +20,3 @@ dev_dependencies: sdk: flutter flutter: - plugin: - platforms: - android: - package: com.github.chinloyal.pusher_client - pluginClass: PusherClientPlugin - ios: - pluginClass: PusherClientPlugin From 3e49e9d15492c44dae45460cf01e456c74f15789 Mon Sep 17 00:00:00 2001 From: Djihanegh Date: Wed, 29 Sep 2021 11:40:53 +0200 Subject: [PATCH 4/5] fixing singleton problem --- lib/src/pusher/pusher_client.dart | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/src/pusher/pusher_client.dart b/lib/src/pusher/pusher_client.dart index 1e8054e..010b96d 100644 --- a/lib/src/pusher/pusher_client.dart +++ b/lib/src/pusher/pusher_client.dart @@ -21,12 +21,12 @@ class PusherClient extends StreamHandler { const MethodChannel('com.github.chinloyal/pusher_client'); static const classId = 'PusherClient'; - static PusherClient? _singleton; + // static PusherClient? _singleton; void Function(ConnectionStateChange?)? _onConnectionStateChange; void Function(ConnectionError?)? _onConnectionError; String? _socketId; - /* PusherClient._( + /* PusherClient._( String appKey, PusherOptions options, { bool enableLogging = true, @@ -49,12 +49,12 @@ class PusherClient extends StreamHandler { //PusherOptions? options; /// Creates a [PusherClient] -- returns the instance if it's already be called. - PusherClient( + /* PusherClient( String appKey, PusherOptions options, { bool enableLogging = true, bool autoConnect = true, - }); /*{ + });*/ /*{ _singleton ??= PusherClient._( appKey, options, @@ -76,6 +76,7 @@ class PusherClient extends StreamHandler { // PusherOptions getOptions() => options!; Future _init(String appKey, PusherOptions options, InitArgs initArgs) async { + print("PUSHERRRR CONNECTTTTT"); registerListener(classId, _eventHandler); await _channel.invokeMethod( 'init', From b558512c3ac4e2b68b89775489130e926ab039ee Mon Sep 17 00:00:00 2001 From: Djihanegh Date: Wed, 29 Sep 2021 11:42:52 +0200 Subject: [PATCH 5/5] deleted tests --- example/lib/main.dart | 3 ++- example/test/widget_test.dart | 3 ++- test/pusher_client_test.dart | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/example/lib/main.dart b/example/lib/main.dart index 61811e5..d099f1f 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,4 +1,4 @@ -import 'dart:developer'; +/*import 'dart:developer'; import 'package:flutter/material.dart'; import 'package:pusher_client/pusher_client.dart'; @@ -107,3 +107,4 @@ class _MyAppState extends State { ); } } +*/ \ No newline at end of file diff --git a/example/test/widget_test.dart b/example/test/widget_test.dart index a856418..be8758d 100644 --- a/example/test/widget_test.dart +++ b/example/test/widget_test.dart @@ -5,7 +5,7 @@ // gestures. You can also use WidgetTester to find child widgets in the widget // tree, read text, and verify that the values of widget properties are correct. -import 'package:flutter/material.dart'; +/*import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:pusher_client_example/main.dart'; @@ -25,3 +25,4 @@ void main() { ); }); } +*/ \ No newline at end of file diff --git a/test/pusher_client_test.dart b/test/pusher_client_test.dart index a959c84..af414c5 100644 --- a/test/pusher_client_test.dart +++ b/test/pusher_client_test.dart @@ -1,4 +1,4 @@ -import 'package:flutter/material.dart'; +/*import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:pusher_client/pusher_client.dart'; @@ -30,4 +30,4 @@ void main() { // test() }); -} +}*/