onTransportData method

void onTransportData(
  1. Transport transport,
  2. String messageData
)

Implementation

void onTransportData(Transport transport, String messageData) {
  IncomingMessage? message = Parser.parseMessage(messageData, this);

  if (message == null) {
    return;
  }

  if (_status == C.STATUS_USER_CLOSED && message is IncomingRequest) {
    return;
  }

  // Do some sanity check.
  if (!sanityCheck(message, this, transport)) {
    return;
  }

  if (message is IncomingRequest) {
    message.transport = transport;
    receiveRequest(message);
  } else if (message is IncomingResponse) {
    /* Unike stated in 18.1.2, if a response does not match
  * any transaction, it is discarded here and no passed to the core
  * in order to be discarded there.
  */

    switch (message.method) {
      case SipMethod.INVITE:
        InviteClientTransaction? transaction = _transactions.getTransaction(
            InviteClientTransaction, message.via_branch!);
        if (transaction != null) {
          transaction.receiveResponse(message.status_code, message);
        }
        break;
      case SipMethod.ACK:
        // Just in case ;-).
        break;
      default:
        NonInviteClientTransaction? transaction = _transactions
            .getTransaction(NonInviteClientTransaction, message.via_branch!);
        if (transaction != null) {
          transaction.receiveResponse(message.status_code, message);
        }
        break;
    }
  }
}