From 9f5cf692c2d301ce8eae3717e2b0048b49667e3f Mon Sep 17 00:00:00 2001 From: Aslam Anver Date: Mon, 28 Oct 2019 17:35:45 +0530 Subject: [PATCH 1/4] Socket.IO Reconnecting issue fixed with downgrading version Java Socket.IO --- android/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/build.gradle b/android/build.gradle index a29e7ef..463fa69 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -34,7 +34,7 @@ android { } dependencies { - implementation ('io.socket:socket.io-client:1.0.0') { + implementation ('io.socket:socket.io-client:0.8.3') { // excluding org.json which is provided by Android exclude group: 'org.json', module: 'json' } From 0f0159a6e5597201e4fc62fe7fc3a6019132df86 Mon Sep 17 00:00:00 2001 From: Aslam Anver Date: Wed, 30 Oct 2019 13:30:06 +0530 Subject: [PATCH 2/4] Readme improved with latest code changes --- README.md | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index eb131c3..5414374 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,10 @@ # adhara_socket_io -socket.io for flutter by adhara +Socket.IO for flutter by adhara -supports both Android and iOS +Supports both Android and iOS - -Usage: +## Usage: See `example/lib/main.dart` for better example @@ -23,13 +22,16 @@ See `example/lib/main.dart` for better example print(data); socket.emit("message", ["Hello world!"]); }); + socket.on("news", (data){ //sample event print("news"); print(data); }); + socket.connect(); + ///disconnect using - ///manager. + ///manager ``` @@ -43,7 +45,6 @@ To request callback on ack: ## Running example: - 1. Open `example/ios` in XCode or `example/android` in android studio. Build the code once (`cd example` & `flutter build apk` | `flutter build ios --no-codesign`) 2. cd `example/socket.io.server` @@ -63,20 +64,17 @@ To request callback on ack: const String URI = "http://mysite.com/"; ``` -4. run Android/iOS app +4. Run Android/iOS app ## iOS support 📢📢 This project uses Swift for iOS support, please enable Swift support for your project for this plugin to work - ## Android support for SDK > 27 -Configure `android:usesCleartextTraffic="true"` as a property of `` tag in `android/app/src/main/AndroidManifest.xml` +In Android `android/app/src/main/AndroidManifest.xml` file add `usesCleartextTraffic` in application tag. For example: - ```xml - ... - ``` [Refer to discussion here](https://github.com/infitio/flutter_socket_io/issues/42) @@ -104,5 +101,4 @@ https://github.com/infitio/flutter_socket_io/blob/master/example/ios/Podfile#L30 ## Other Packages: - Feel free to checkout our [Adhara](https://pub.dartlang.org/packages/adhara) package From 297af31ead2bb6b955cbceb5ef1d1d8d209d5e07 Mon Sep 17 00:00:00 2001 From: Aslam Anver Date: Wed, 30 Oct 2019 13:31:30 +0530 Subject: [PATCH 3/4] Code formatted --- README.md | 47 +++++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 5414374..f06c28c 100644 --- a/README.md +++ b/README.md @@ -9,30 +9,29 @@ Supports both Android and iOS See `example/lib/main.dart` for better example ```dart - SocketIOManager manager = SocketIOManager(); - SocketIO socket = manager.createInstance( - SocketOptions('http://192.168.1.12:5555', //TODO change the port accordingly - nameSpace: '/yournamespace', - enableLogging: true, - transports: [Transports.POLLING]) - ); - - socket.onConnect((data){ - print("connected..."); - print(data); - socket.emit("message", ["Hello world!"]); - }); - - socket.on("news", (data){ //sample event - print("news"); - print(data); - }); - - socket.connect(); - - ///disconnect using - ///manager - +SocketIOManager manager = SocketIOManager(); +SocketIO socket = manager.createInstance( + SocketOptions('http://192.168.1.12:5555', //TODO change the port accordingly + nameSpace: '/yournamespace', + enableLogging: true, + transports: [Transports.POLLING]) +); + +socket.onConnect((data){ + print("connected..."); + print(data); + socket.emit("message", ["Hello world!"]); +}); + +socket.on("news", (data){ //sample event + print("news"); + print(data); +}); + +socket.connect(); + +///disconnect using +///manager ``` To request callback on ack: From 134cd3f585e2f406c8f60706222bdf930e1d8774 Mon Sep 17 00:00:00 2001 From: Aslam Anver Date: Wed, 30 Oct 2019 13:33:21 +0530 Subject: [PATCH 4/4] Code format --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f06c28c..89eec05 100644 --- a/README.md +++ b/README.md @@ -36,10 +36,10 @@ socket.connect(); To request callback on ack: ```dart - socket.emitWithAck("message", ["Hello world!"]).then( (data) { - // this callback runs when this specific message is acknowledged by the server - print(data); - }); +socket.emitWithAck("message", ["Hello world!"]).then( (data) { + // this callback runs when this specific message is acknowledged by the server + print(data); +}); ``` ## Running example: