Skip to content

Commit

Permalink
Adding params support for sendMessage (#366)
Browse files Browse the repository at this point in the history
* Adding params support for sendMessage

* Add sendMessage to Call

* Add body to options if key is not setted

* Fix error message on sendMessage method

* Upgrading intl dependency

---------

Co-authored-by: EduardoAlberti <[email protected]>
  • Loading branch information
FeleConvo and EduardoAlberti authored May 11, 2023
1 parent 809f50c commit ad8ed79
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
7 changes: 4 additions & 3 deletions lib/src/message.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ class Message extends EventManager with Applicant {

Map<String, dynamic>? get data => _data;

void send(String target, String body, [Map<String, dynamic>? options]) {
void send(String target, String body,
[Map<String, dynamic>? options, Map<String, dynamic>? params]) {
String originalTarget = target;
options = options ?? <String, dynamic>{};

Expand All @@ -56,8 +57,8 @@ class Message extends EventManager with Applicant {

extraHeaders.add('Content-Type: $contentType');

_request =
OutgoingRequest(SipMethod.MESSAGE, normalized, _ua, null, extraHeaders);
_request = OutgoingRequest(
SipMethod.MESSAGE, normalized, _ua, params, extraHeaders);
if (body != null) {
_request.body = body;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/src/sip_ua_helper.dart
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,8 @@ class SIPUAHelper extends EventManager {
}

Message sendMessage(String target, String body,
[Map<String, dynamic>? options]) {
return _ua!.sendMessage(target, body, options);
[Map<String, dynamic>? options, Map<String, dynamic>? params]) {
return _ua!.sendMessage(target, body, options, params);
}

void subscribe(String target, String event, String contentType) {
Expand Down
14 changes: 7 additions & 7 deletions lib/src/ua.dart
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ class UA extends EventManager {
_registrator.unregister(all);
}

/**
/**
* Create subscriber instance
*/
Subscriber subscribe(
Expand Down Expand Up @@ -261,11 +261,11 @@ class UA extends EventManager {
* -throws {TypeError}
*
*/
Message sendMessage(
String target, String body, Map<String, dynamic>? options) {
Message sendMessage(String target, String body, Map<String, dynamic>? options,
Map<String, dynamic>? params) {
logger.d('sendMessage()');
Message message = Message(this);
message.send(target, body, options);
message.send(target, body, options, params);
return message;
}

Expand Down Expand Up @@ -897,9 +897,9 @@ class UA extends EventManager {
return;
}

/**
* Transport event handlers
*/
/**
* Transport event handlers
*/

// Transport connecting event.
void onTransportConnecting(WebSocketInterface? socket, int? attempts) {
Expand Down

0 comments on commit ad8ed79

Please sign in to comment.