stasisStart function

dynamic stasisStart(
  1. StasisStart event,
  2. Channel channel
)

Implementation

stasisStart(StasisStart event, Channel channel) {
  bool dialed = event.args.length > 0 ? event.args[0] == 'dialed' : false;

  if (channel.name.contains('UnicastRTP')) {
    print('Channel ${channel.name} has entered our application');
    dialed = true;
  }

  if (!dialed) {
    var resp = channel.answer();
    resp.then((err) {
      print('Channel ${channel.name} has entered our application');

      cdrRecords[channel.id] = Cdr(
          channel: channel.id,
          clid: channel.caller.name,
          src: channel.caller.number,
          dst: 'c-17',
          dcontext: 'custom-context',
          calldate: event.timestamp.toString());

      originate(channel);
    });
  }
}