adhara_socket_io 0.2.0

adhara_socket_io #

socket.io for flutter by adhara

supports both Android and iOS

Usage:

See example/lib/main.dart for better example

    SocketIOManager manager = SocketIOManager();
    SocketIO socket = manager.createInstance('http://192.168.1.2:7000/');       //TODO change the port  accordingly
    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.

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

  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

Feel free to checkout our Adhara package

0.2.0 - 5th June, 2019 #

Breaking Change #

  • Convert all arguments for SocketIOManager to a single Options object

old config

socket = await manager.createInstance(
  URI,
  query: {"auth": "--SOME AUTH STRING---",},
  enableLogging: false
);

new config

socket = await manager.createInstance(SocketOptions(
    URI,
    query: {"auth": "--SOME AUTH STRING---",},
    enableLogging: false,
));
  • Introducing transports in SocketOptions

0.1.11 - 5th June, 2019 #

0.1.10 - 26th February, 2019 #

  • clearInstance BugFix on iOS

0.1.9 - 21st January, 2019 #

  • BugFix for iOS running on iPhone 6

0.1.8 - 17th January, 2019 #

  • Optimized serialization code for Android
  • Bug fix for Map representation characters/reserved characters for map representation as a string (= and /)

0.1.7 - 17th January, 2019 #

  • Disabling unnecessary logging of events in platform implementations in both Android and iOS, can enable if required by passing enableLogging: true to createInstance

0.1.6 - 28th November, 2018 #

  • Android and iOS data serialization handled properly to send objects and arrays

0.1.4 - 28th November, 2018 #

  • Android query bug: Extra ? is being sent. fixed

0.1.3 - 21st November, 2018 #

  • Added support for socket.io handshake query params for both iOS and Android

0.1.2 - 20th November, 2018 #

  • Fully working version of basic Socket.io connection for both Android and iOS

example/README.md

adhara_socket_io_example #

Usage:

See example/lib/main.dart for better example


    SocketIO socket = await SocketIOManager().createInstance('http://192.168.1.2:7000/');       //TODO change the port  accordingly
    socket.onConnect((data){
      print("connected...");
      print(data);
      socket.emit("message", ["Hello world!"]);
    });
    socket.on("news", (data){   //sample event
      print("news");
      print(data);
    });
    socket.connect();

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

  4. run Android/iOS app

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  adhara_socket_io: ^0.2.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:adhara_socket_io/adhara_socket_io.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
91
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
95
Learn more about scoring.

We analyzed this package on Jul 17, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.4.0
  • pana: 0.12.19
  • Flutter: 1.7.8+hotfix.3

Platforms

Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Health suggestions

Fix lib/socket.dart. (-0.50 points)

Analysis of lib/socket.dart reported 1 hint:

line 58 col 35: This function has a return type of 'Future', but doesn't end with a return statement.

Format lib/options.dart.

Run flutter format to format lib/options.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8

Admin