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');
    print(channel.handlers);
    dialed = true;

    rtpPortCounter++;
    if (rtpPortCounter - port > 2000) rtpPortCounter = 0;
  }
  if (!dialed) {
    //throw variable;
    channel.answer((err) {
      if (err) {
        throw err;
      }

      print('Channel ${channel.name} has entered our application');

      getOrCreateHoldingBridge(channel);
    });

    actveCalls[channel.id] = channel.id;
    callsWaiting[channel.id] = channel.id;
    CallsInConversation[channel.id] = channel.id;

    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());

    //actveCalls.set(channel.id, channel.id);
    //callsWaiting.set(channel.id, channel.id);

    //errors.set(channel.id, 0);
    //sendCdr();
  }
  // else{
  //   if(event.args.length > 0 && event.args[0] == 'dialed'){

  //   }

  // }
}