From 1cbe44eed5c7c56b59dc6176b2000fecb2d82bcc Mon Sep 17 00:00:00 2001 From: Felipe Medeiros B Date: Tue, 18 Apr 2023 14:32:55 -0400 Subject: [PATCH 1/5] Adding params support for sendMessage --- lib/src/message.dart | 7 ++++--- lib/src/sip_ua_helper.dart | 4 ++-- lib/src/ua.dart | 14 +++++++------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/lib/src/message.dart b/lib/src/message.dart index 3e151070..2aeffe49 100644 --- a/lib/src/message.dart +++ b/lib/src/message.dart @@ -32,7 +32,8 @@ class Message extends EventManager with Applicant { Map? get data => _data; - void send(String target, String body, [Map? options]) { + void send(String target, String body, + [Map? options, Map? params]) { String originalTarget = target; options = options ?? {}; @@ -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; } diff --git a/lib/src/sip_ua_helper.dart b/lib/src/sip_ua_helper.dart index 39f9ff86..994ac536 100644 --- a/lib/src/sip_ua_helper.dart +++ b/lib/src/sip_ua_helper.dart @@ -345,8 +345,8 @@ class SIPUAHelper extends EventManager { } Message sendMessage(String target, String body, - [Map? options]) { - return _ua!.sendMessage(target, body, options); + [Map? options, Map? params]) { + return _ua!.sendMessage(target, body, options, params); } void subscribe(String target, String event, String contentType) { diff --git a/lib/src/ua.dart b/lib/src/ua.dart index 0216e79a..581a6ee8 100644 --- a/lib/src/ua.dart +++ b/lib/src/ua.dart @@ -195,7 +195,7 @@ class UA extends EventManager { _registrator.unregister(all); } - /** + /** * Create subscriber instance */ Subscriber subscribe( @@ -261,11 +261,11 @@ class UA extends EventManager { * -throws {TypeError} * */ - Message sendMessage( - String target, String body, Map? options) { + Message sendMessage(String target, String body, Map? options, + Map? params) { logger.d('sendMessage()'); Message message = Message(this); - message.send(target, body, options); + message.send(target, body, options, params); return message; } @@ -897,9 +897,9 @@ class UA extends EventManager { return; } -/** - * Transport event handlers - */ + /** + * Transport event handlers + */ // Transport connecting event. void onTransportConnecting(WebSocketInterface? socket, int? attempts) { From e2ed8a6c42a314cf89fa40612d8eb82b16d0f60c Mon Sep 17 00:00:00 2001 From: EduardoAlberti Date: Wed, 19 Apr 2023 12:30:03 -0400 Subject: [PATCH 2/5] Add sendMessage to Call --- lib/src/sip_ua_helper.dart | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/src/sip_ua_helper.dart b/lib/src/sip_ua_helper.dart index 39f9ff86..8970340f 100644 --- a/lib/src/sip_ua_helper.dart +++ b/lib/src/sip_ua_helper.dart @@ -507,6 +507,11 @@ class Call { _session.sendInfo(contentType, body, options); } + void sendMessage(String body, [Map? options]) { + assert(_session != null, 'ERROR(sendInfo): rtc session is invalid'); + _session.sendRequest(DartSIP_C.SipMethod.MESSAGE, options); + } + String? get remote_display_name { assert(_session != null, 'ERROR(get remote_identity): rtc session is invalid!'); From b24c359c8450b3b0470ed0ad6e20d7ff59f1e902 Mon Sep 17 00:00:00 2001 From: EduardoAlberti Date: Wed, 19 Apr 2023 12:36:00 -0400 Subject: [PATCH 3/5] Add body to options if key is not setted --- lib/src/sip_ua_helper.dart | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/src/sip_ua_helper.dart b/lib/src/sip_ua_helper.dart index 8970340f..28e78343 100644 --- a/lib/src/sip_ua_helper.dart +++ b/lib/src/sip_ua_helper.dart @@ -509,7 +509,11 @@ class Call { void sendMessage(String body, [Map? options]) { assert(_session != null, 'ERROR(sendInfo): rtc session is invalid'); - _session.sendRequest(DartSIP_C.SipMethod.MESSAGE, options); + + options?.putIfAbsent('body', () => body); + + _session.sendRequest(DartSIP_C.SipMethod.MESSAGE, + options ?? {'body': body}); } String? get remote_display_name { From eff932a2694f885f7089780189a74625a657f812 Mon Sep 17 00:00:00 2001 From: EduardoAlberti Date: Wed, 19 Apr 2023 15:41:26 -0400 Subject: [PATCH 4/5] Fix error message on sendMessage method --- lib/src/sip_ua_helper.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/src/sip_ua_helper.dart b/lib/src/sip_ua_helper.dart index 28e78343..10ed3c5e 100644 --- a/lib/src/sip_ua_helper.dart +++ b/lib/src/sip_ua_helper.dart @@ -508,7 +508,7 @@ class Call { } void sendMessage(String body, [Map? options]) { - assert(_session != null, 'ERROR(sendInfo): rtc session is invalid'); + assert(_session != null, 'ERROR(sendMessage): rtc session is invalid'); options?.putIfAbsent('body', () => body); From 57f443b8f1b7bdeb94194012d49ecba1019b07e2 Mon Sep 17 00:00:00 2001 From: Felipe Medeiros B Date: Wed, 19 Apr 2023 21:21:28 -0400 Subject: [PATCH 5/5] Upgrading intl dependency --- pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index fe16796f..16d2d656 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -10,7 +10,7 @@ dependencies: collection: ^1.15.0 crypto: ^3.0.0 flutter_webrtc: ^0.9.25 - intl: ^0.17.0 + intl: ^0.18.1 logger: ^1.0.0 parser_error: ^0.2.0 path: ^1.6.4