socket_io_flutter 1.0.0 copy "socket_io_flutter: ^1.0.0" to clipboard
socket_io_flutter: ^1.0.0 copied to clipboard

discontinued
outdated

Socket.io plugin, supports iOS and Android.

socket_io_flutter #

socket.io with timeout config. supports both Android and iOS

Usage:

See example/lib/main.dart for better example

    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:

  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

    1 run npm i

    2 run npm start

  3. open example/lib/main.dart and edit the URI in #7 to point to your hosted/local socket server instances as mentioned step 2

    For example:

    const String URI = "http://192.168.1.2:7000/";
    
    const String URI = "http://mysite.com/";
    
  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

For example:


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

Based on Adhara socket.io

1
likes
0
pub points
18%
popularity

Publisher

unverified uploader

Socket.io plugin, supports iOS and Android.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on socket_io_flutter