app_ivr function

void app_ivr(
  1. List<String> arguments
)

Implementation

void app_ivr(List<String> arguments) async {
  var env = DotEnv(includePlatformEnvironment: true)..load();
  //rtpIp = env['RTP_ADDRESS']!;
  //port = int.parse(env['RTP_PORT']!);
  //print("Listening on: $rtpIp:$port");
  destinations['1'] = Extension('custom-contexts', '1', 'cc-3');

  destinations['2'] = Extension('custom-contexts', '1', 'cc-7');

  destinations['3'] = Extension('app-ivr', '1', 'IVR-12');

  destinations['4'] = Extension('custom-contexts', '1', 'cc-6');

  destinations['5'] = Extension('app-ivr', '1', 'IVR-13');

  destinations['6'] = Extension('app-ivr', '1', 'IVR-11');

  destinations['7'] = Extension('custom-contexts', '1', 'cc-17');

  destinations['8'] = Extension('custom-contexts', '1', 'cc-21');

  destinations['9'] = Extension('custom-contexts', '1', 'cc-16');

  String wsIp = env['WS_SERVER_ADDRESS']!;
  int wsPort = int.parse(env['WS_SERVER_PORT']!);
  String redisIp = env['REDIS_ADDRESS']!;
  int redisPort = int.parse(env['REDIS_PORT']!);
  String redisPassword = env['REDIS_PASSWORD']!;

  //endpoint = env['PHONE_ENDPOINT']!;
  //print("Endpoint: $endpoint");
  wsServer = WsServer(wsIp, wsPort, redisIp, redisPort, redisPassword);

  String voice_records = env['DASHBOARD_RECORDER_ENDPOINT']!;
  String cdr_records = env['DASHBOARD_CDR_ENDPOINT']!;

  dsbClient = DasboardClient(Uri.parse(voice_records), Uri.parse(cdr_records));

  //wsServer!.intialize();
  // wsSipServer proxy=wsSipServer("127.0.0.1",8082);
  // proxy.intialize();

  client.on("StasisStart", (event, incoming) {
    //print(event);
    stasisStart(event, incoming);
  });

  client.on('StasisEnd', (event, incoming) {
    // incoming.answer(err => {
    // if (err) { debug('incoming.answer error:', err);
    // console.log(`Error: ${err}`);
    // }
    // getOrCreateHoldingBridge(incoming);
    // });
    // var cdr: Cdr = {};
    // cdr.calldate = event.timestamp;
    // cdr.accountcode = event.channel.accountcode;
    // cdr.clid = event.channel.caller;
    // cdr.channel = event.channel.id;
    // cdr.src = event.channel.caller.number;

    stasisEnd(event, incoming);
  });

  WebSocket ws = await client.connect();

  ws.listen((event) {
    var e = json.decode(event);
    //print(e['type']);
    client.emit(e);

    // Function? func = app[e['type']];
    // func!.call(e);
  });
}