aidio 1.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 59

Aid.io Dart #

Simple Dart Socket library in Dart

Protocol: [cmd,ack,data.size,data] Uint8 in Dart

Explain: head(10byte) [cmd:1,ack:1,size:8] body:[data]

Server Usage #

Server.dart - Example

import 'package:aidio/io.dart';

main() async {
  var io = AidioServer();
  await io.init(host: '127.0.0.1', port: 1999);
  io.stream.listen((AidioData data) {
    print("recieve:$data");
  });
}

Client Usage #

Client.dart - Example

import 'package:aidio/io.dart';

main() async {
  var io = AidioClient();
  await io.init(host: '127.0.0.1', port: 1999);
  var tick = 0;
  io.stream.listen((AidioData data) {
    print("recieve:$data");
    tick++;
    if (tick > 10) {
      io.close();
      return;
    }
    Future.delayed(Duration(seconds: 1), () {
      io.send(IoCommond.emit, "timer:${tick}");
    });
  });
}

Document #

IoCommonds


enum IoCommond {
  none,
  error,
  connected,
  denied,
  ack,
  msg,
  emit,
  ///  here set up your commonds, if you need
}

AidioServer


class AidioServer extends AidioProtocol {
  bool auth = false;

  init({String host = '127.0.0.1', int port = 4041}) async {
    try {
      io = await ServerSocket.bind(host, port);
      ....
    } catch (e) {
      ....  
    }
  }
}

AidioServer


class AidioClient extends AidioProtocol {
  init({String host = '127.0.0.1', int port = 4041}) async {
    try {
      socket = await Socket.connect(host, port);
      ....
    } catch (e) {
      ....
    }
  }
}

Protocol #

Data Transform Package Format:

[cmd,ack,data.size,data]

Example Process:


 *   1.client-> auth to ->server
 *   2.client receive [IoCommond.connected,0,data.size,data] or [IoCommond.denied,0,data.size,data]
 *   3.client send [IoCommond.file,0,data.size,data]
 *   4.server receive [IoCommond.file,1,data.size,data]

Contributors #

AlmPazel, Fehrim, Dina, Jaffar

Welcome to join [Contributors] !

1.0.1 #

Releasing:

  • fixed publish requires, clean up codes and fix code style

1.0.0+5 #

Releasing:

  • fixed publish requires, clean up codes

example/main.dart

import 'package:aidio/aidio.dart';

main() async {
  var io = AidioClient();
  await io.init(host: '127.0.0.1', port: 1999);
  var tick = 0;
  io.stream.listen((AidioData data) {
    print("recieve:$data");
    tick++;
    if (tick > 10) {
      io.close();
      return;
    }
    Future.delayed(Duration(seconds: 1), () {
      io.send(IoCommond.emit, "timer:${tick}");
    });
  });
}

Use this package as a library

1. Depend on it

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


dependencies:
  aidio: ^1.0.1

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or 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:aidio/aidio.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
19
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]
59
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.15

Analysis suggestions

Package not compatible with runtime flutter-web on Web

Because:

  • package:aidio/aidio.dart that imports:
  • package:aidio/src/aidio.dart that imports:
  • dart:io

Package not compatible with runtime js

Because:

  • package:aidio/aidio.dart that imports:
  • package:aidio/src/aidio.dart that imports:
  • dart:io

Health suggestions

Format lib/src/aidio.dart.

Run dartfmt to format lib/src/aidio.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.6.0 <3.0.0