Code Monkey home page Code Monkey logo

ami_flutter's Introduction

ami_flutter

Asterisk Manager Interface (AMI) Library for Flutter


Features

  • support Android,iOS,Desktop and Web.
  • support listen events from stream.
  • support async/await for ami events.
  • functions organized by module, developers can combine them for other purpose.
  • easy to develop new actions or connection methods.

Installation

just add dependency into pubspec.yaml:

ami_flutter: ^0.0.2

Usage

  1. initialize derived classes of BaseManager (e.g. DefaultManager for TCP Socket or WebSocketManager for WebSocket at web platform) and connect:
final manager = DefaultManager();
// web platform need set prefix for send actions, like this: manager.prefix = 'prefix';
manager.init();
await manager.connect('127.0.0.1', 5038);
  1. login ami:
final loginResult = await manager.login('user', 'pass');
  1. send actions and receive responses:
final statusResult = await manager.sendAction('Status');
final originateResult = await manager.sendAction(
     'Originate',
     id: 'actionId',
     args: {
       'Channel': 'sip/12345',
       'Exten': '1234',
       'Context': 'default',
       'Async': 'yes',
     },
   );
  1. listen events:
manager.registerEvent('DongleSMSStatus').listen(
     (event) {
       print('receive event ${event.name} ${event.baseMsg.headers}');
     },
   );

or read events like response:

final bootedEvent = await manager.readEvent('FullyBooted');
final events = await manager.readAllEventsUntil(
     'DongleDeviceEntry',
     'DongleShowDevicesComplete',
   );
  1. logoff and dispose resource:
await manager.logoff();
manager.dispose();

Web Platform Need Know

AMI only support TCP socket. If you need use the library at web platform:

  • Install and configure amiws.
  • Use WebSocketManager to connect web socket proxy by amiws

BTW. You can use function selectByPlatform to auto select the proper manager according to your platform.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.