Skip to content

Socket.IO Reconnecting issue fixed with downgrading version Java Sock… #96

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 32 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
# 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

```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:
```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:


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`

Expand All @@ -63,28 +63,24 @@ 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 `<application ...>` 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

<application
android:name="io.flutter.app.FlutterApplication"
android:label="adhara_socket_io_example"
android:usesCleartextTraffic="true"
android:icon="@mipmap/ic_launcher">
<activity
android:name=".MainActivity"...>...</activity>

```

[Refer to discussion here](https://github.com/infitio/flutter_socket_io/issues/42)
Expand All @@ -104,5 +100,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
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
}
Expand Down