Skip to content

Commit 0e5256a

Browse files
PerondasPerondasPerondas
authored
Subscribe support (#269)
* Implemented subscribe support like here versatica/JsSIP#711 * Fixed type Errors * Made events consistant * Chore: Began Subscriber rework * Feat: Implemented subscribe support * Changed subscriber id to be the call id * Added termination to subscribers * Moved back sdk version to 2.14.0 * Fixed unrealted bug in hangup * Made imports relative Co-authored-by: Perondas <[email protected]> Co-authored-by: Perondas <[email protected]>
1 parent 5758d2f commit 0e5256a

16 files changed

+744
-17
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ pubspec.lock
1313
doc/api/
1414
.DS_Store
1515
example/lib/generated_plugin_registrant.dart
16+
17+
.flutter-plugins
18+
.flutter-plugins-dependencies

example/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,5 @@
7171
!**/ios/**/default.pbxuser
7272
!**/ios/**/default.perspectivev3
7373
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
74+
75+
.flutter-plugins-dependencies

example/lib/src/callscreen.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,4 +581,9 @@ class _MyCallScreenWidget extends State<CallScreenWidget>
581581
void onNewMessage(SIPMessageRequest msg) {
582582
// NO OP
583583
}
584+
585+
@override
586+
void onNewNotify(Notify ntf) {
587+
// TODO: implement onNewNotify
588+
}
584589
}

example/lib/src/dialpad.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,4 +311,9 @@ class _MyDialPadWidget extends State<DialPadWidget>
311311
receivedMsg = msgBody;
312312
});
313313
}
314+
315+
@override
316+
void onNewNotify(Notify ntf) {
317+
// TODO: implement onNewNotify
318+
}
314319
}

example/lib/src/register.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,4 +293,9 @@ class _MyRegisterWidget extends State<RegisterWidget>
293293
void onNewMessage(SIPMessageRequest msg) {
294294
// NO OP
295295
}
296+
297+
@override
298+
void onNewNotify(Notify ntf) {
299+
// TODO: implement onNewNotify
300+
}
296301
}

lib/src/constants.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ Map<int, String> REASON_PHRASE = <int, String>{
209209
};
210210

211211
const String ALLOWED_METHODS =
212-
'INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO';
212+
'INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO,NOTIFY';
213213
const String ACCEPTED_BODY_TYPES = 'application/sdp, application/dtmf-relay';
214214
const int MAX_FORWARDS = 69;
215215
const int SESSION_EXPIRES = 90;

lib/src/dialog.dart

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Id {
3636

3737
// RFC 3261 12.1.
3838
class Dialog {
39-
Dialog(RTCSession owner, dynamic message, String type, [int? state]) {
39+
Dialog(Owner owner, dynamic message, String type, [int? state]) {
4040
state = state ?? DialogStatus.STATUS_CONFIRMED;
4141
_owner = owner;
4242
_ua = owner.ua;
@@ -91,7 +91,7 @@ class Dialog {
9191
'$type dialog created with status ${_state == DialogStatus.STATUS_EARLY ? 'EARLY' : 'CONFIRMED'}');
9292
}
9393

94-
RTCSession? _owner;
94+
Owner? _owner;
9595
UA? _ua;
9696
bool uac_pending_reply = false;
9797
bool uas_pending_reply = false;
@@ -108,7 +108,7 @@ class Dialog {
108108
UA? get ua => _ua;
109109
Id? get id => _id;
110110

111-
RTCSession? get owner => _owner;
111+
Owner? get owner => _owner;
112112

113113
void update(dynamic message, String type) {
114114
_state = DialogStatus.STATUS_CONFIRMED;
@@ -263,3 +263,10 @@ class Dialog {
263263
return true;
264264
}
265265
}
266+
267+
abstract class Owner {
268+
Function(IncomingRequest) get receiveRequest;
269+
int? get status;
270+
int get TerminatedCode;
271+
UA? get ua;
272+
}

lib/src/dialog/request_sender.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class DialogRequestSender {
9191
_request.cseq = _dialog.local_seqnum!.toInt();
9292
_reattemptTimer = setTimeout(() {
9393
// TODO(cloudwebrtc): look at dialog state instead.
94-
if (_dialog.owner!.status != RTCSession.C.STATUS_TERMINATED) {
94+
if (_dialog.owner!.status != _dialog.owner!.TerminatedCode) {
9595
_reattempt = true;
9696
_request_sender.send();
9797
}

lib/src/event_manager/internal_events.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,8 @@ class EventOnErrorResponse extends EventType {
161161
EventOnErrorResponse({this.response});
162162
IncomingMessage? response;
163163
}
164+
165+
class EventOnNewSubscribe extends EventType {
166+
EventOnNewSubscribe({this.request});
167+
IncomingRequest? request;
168+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import 'package:sip_ua/src/sip_message.dart';
2+
3+
import 'events.dart';
4+
5+
class EventTerminated extends EventType {
6+
EventTerminated({this.terminationCode, this.sendFinalNotify});
7+
int? terminationCode;
8+
bool? sendFinalNotify;
9+
}
10+
11+
class EventSubscribe extends EventType {
12+
EventSubscribe(
13+
{this.isUnsubscribe, this.request, this.body, this.content_type});
14+
bool? isUnsubscribe;
15+
IncomingRequest? request;
16+
String? body;
17+
String? content_type;
18+
}

0 commit comments

Comments
 (0)