checkTransaction function
INVITE: true if retransmission false request
ACK: true ACK to non2xx response false ACK must be passed to TU (accepted state) ACK to 2xx response
CANCEL: true no matching invite transaction false matching invite transaction and no final response sent
OTHER: true retransmission false request
Implementation
bool checkTransaction(TransactionBag _transactions, IncomingRequest request) {
switch (request.method) {
case SipMethod.INVITE:
InviteServerTransaction? tr = _transactions.getTransaction(
InviteServerTransaction, request.via_branch!);
if (tr != null) {
switch (tr.state) {
case TransactionState.PROCEEDING:
tr.transport!.send(tr.last_response);
break;
// RFC 6026 7.1 Invite retransmission.
// Received while in TransactionState.ACCEPTED state. Absorb it.
case TransactionState.ACCEPTED:
break;
default:
break;
}
return true;
}
break;
case SipMethod.ACK:
InviteServerTransaction? tr = _transactions.getTransaction(
InviteServerTransaction, request.via_branch!);
// RFC 6026 7.1.
if (tr != null) {
if (tr.state == TransactionState.ACCEPTED) {
return false;
} else if (tr.state == TransactionState.COMPLETED) {
tr.state = TransactionState.CONFIRMED;
tr.I = setTimeout(() {
tr.timer_I();
}, Timers.TIMER_I);
return true;
}
}
// ACK to 2XX Response.
else {
return false;
}
break;
case SipMethod.CANCEL:
InviteServerTransaction? tr = _transactions.getTransaction(
InviteServerTransaction, request.via_branch!);
if (tr != null) {
request.reply_sl(200);
if (tr.state == TransactionState.PROCEEDING) {
return false;
} else {
return true;
}
} else {
request.reply_sl(481);
return true;
}
default:
// Non-INVITE Server Transaction RFC 3261 17.2.2.
NonInviteServerTransaction? tr = _transactions.getTransaction(
NonInviteServerTransaction, request.via_branch!);
if (tr != null) {
switch (tr.state) {
case TransactionState.TRYING:
break;
case TransactionState.PROCEEDING:
case TransactionState.COMPLETED:
tr.transport!.send(tr.last_response);
break;
default:
break;
}
return true;
}
break;
}
return false;
}