send method
Implementation
void send(String contentType, String body, Map<String, dynamic> options) {
_direction = 'outgoing';
if (contentType == null) {
throw Exceptions.TypeError('Not enough arguments');
}
// Check RTCSession Status.
if (_session.status != rtc.C.statusConfirmed &&
_session.status != rtc.C.statusWaitingForAck) {
throw Exceptions.InvalidStateError(_session.status);
}
_contentType = contentType;
_body = body;
List<dynamic> extraHeaders = utils.cloneArray(options['extraHeaders']);
extraHeaders.add('Content-Type: $contentType');
_session.newInfo('local', this, _request);
EventManager handlers = EventManager();
handlers.on(EventOnSuccessResponse(), (EventOnSuccessResponse event) {
emit(EventSucceeded(originator: 'remote', response: event.response));
});
handlers.on(EventOnErrorResponse(), (EventOnErrorResponse event) {
emit(EventCallFailed(originator: 'remote', response: event.response));
});
handlers.on(EventOnTransportError(), (EventOnTransportError event) {
_session.onTransportError();
});
handlers.on(EventOnRequestTimeout(), (EventOnRequestTimeout event) {
_session.onRequestTimeout();
});
handlers.on(EventOnDialogError(), (EventOnDialogError event) {
_session.onDialogError();
});
_session.sendRequest(SipMethod.INFO, <String, dynamic>{
'extraHeaders': extraHeaders,
'eventHandlers': handlers,
'body': body
});
}