send method
void
send()
Implementation
void send() {
EventManager handlers = EventManager();
handlers.on(EventOnRequestTimeout(), (EventOnRequestTimeout value) {
_eventHandlers.emit(EventOnRequestTimeout());
});
handlers.on(EventOnTransportError(), (EventOnTransportError value) {
_eventHandlers.emit(EventOnTransportError());
});
handlers.on(EventOnAuthenticated(), (EventOnAuthenticated event) {
_eventHandlers.emit(EventOnAuthenticated(request: event.request));
});
handlers.on(EventOnReceiveResponse(), (EventOnReceiveResponse event) {
_receiveResponse(event.response!);
});
_request_sender = RequestSender(_ua, _request, handlers);
request_sender.send();
// RFC3261 14.2 Modifying an Existing Session -UAC BEHAVIOR-.
if ((_request.method == SipMethod.INVITE ||
(_request.method == SipMethod.UPDATE && _request.body != null)) &&
request_sender.clientTransaction.state != TransactionState.TERMINATED) {
_dialog.uac_pending_reply = true;
EventManager eventHandlers = request_sender.clientTransaction;
late void Function(EventStateChanged data) stateChanged;
stateChanged = (EventStateChanged data) {
if (request_sender.clientTransaction.state ==
TransactionState.ACCEPTED ||
request_sender.clientTransaction.state ==
TransactionState.COMPLETED ||
request_sender.clientTransaction.state ==
TransactionState.TERMINATED) {
eventHandlers.remove(EventStateChanged(), stateChanged);
_dialog.uac_pending_reply = false;
}
};
eventHandlers.on(EventStateChanged(), stateChanged);
}
}