Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Subscribe support #711

Open
wants to merge 84 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
ab46c2a
added subscribe support
ikq May 13, 2021
6469fc3
alternative authentication
ikq May 13, 2021
e8f43c9
merged
ikq May 13, 2021
503c60c
subscribe support
ikq May 13, 2021
b9b7f31
Merge branch 'subscribe_support' of https://github.com/ikq/JsSIP into…
ikq May 13, 2021
8ef4afc
subscribe support
ikq May 13, 2021
be1df6d
Merge branch 'subscribe_support' of https://github.com/ikq/JsSIP into…
ikq May 13, 2021
6636713
added subscriber/notifier to JsSIP
ikq May 20, 2021
1220e96
Added Subscriber.js Notifier.js
ikq May 20, 2021
acf80d7
Added Subscriber.js Notifier.js
ikq May 20, 2021
2a8e0b1
style changed
ikq May 21, 2021
b9119ff
style changed
ikq May 21, 2021
ea58279
Merge branch 'subscribe_support' of https://github.com/ikq/JsSIP into…
ikq May 21, 2021
fe32ca3
added *.ts definitions
ikq May 21, 2021
1ceeb78
added *.ts definitions
ikq May 21, 2021
459baa9
edited ts definition
ikq May 21, 2021
825d6ad
subscriber/notifer contact changed
ikq May 21, 2021
b8ab24c
modified Allow-Events
ikq May 22, 2021
1e28648
added check if is_first_notify_request
ikq May 22, 2021
55ea3ce
undefined params is supported
ikq May 23, 2021
0d5dcdc
Added comments for public methods
ikq May 23, 2021
d77e41c
added public method comments
ikq May 23, 2021
7099def
added public method argument descriptions
ikq May 23, 2021
7c935c4
Notifier: termination reason changed to number
ikq May 23, 2021
89fe3d5
Subscriber termination text changed to code
ikq May 24, 2021
15cf6dd
changed constant name RECEIVE
ikq May 24, 2021
a11eb27
Added missed NOTIFY Contact
ikq May 24, 2021
7db192e
Added missed NOTIFY Contact
ikq May 24, 2021
75d2bc0
check NOTIFY event id
ikq May 25, 2021
7ffaf2f
added FAILED_AUTHENTICATION & bug fixing
ikq May 25, 2021
3c8d440
notifier terminated. bug fixing
ikq May 25, 2021
fd1c6d0
style: private starts with _
ikq May 25, 2021
d23b477
improved ts definitions
ikq May 26, 2021
b4d2535
subscriber termination according rfc 6665 4.1.2
ikq May 26, 2021
293344a
adding fetch-subscribe support. work in progress
ikq May 26, 2021
8347714
added fetch-subscribe support
ikq May 27, 2021
4799f57
method arguments use camelCase
ikq May 27, 2021
6f5d248
added terminated reason and retry-after
ikq May 27, 2021
582d205
improved comment
ikq May 28, 2021
f30ad3b
fixed: Notifier expires_timer is not updated
ikq May 28, 2021
5569b5f
comments about state
ikq May 28, 2021
933247f
fixed: NOTIFY Subscription-State expires is small. Update expires tim…
ikq May 28, 2021
ec42af7
subscriber: optional custom contact and cseq
ikq May 31, 2021
491a208
subscriber: custom contact set via headers, not as special argument
ikq May 31, 2021
1df3b9c
Update lib/Notifier.js
ikq Jun 1, 2021
6258013
points at end of sentence
ikq Jun 1, 2021
d77ffde
after review modifications
ikq Jun 1, 2021
3b12423
fixed: Subscriber check matching Notify event
ikq Jun 1, 2021
1238dde
Merge branch 'master' into subscribe_support
ikq Jun 2, 2021
699b463
subscriber/notifer state is number
ikq Jun 5, 2021
6533f4f
merge with latest JsSIP
ikq Jun 5, 2021
9d47a6d
added emit newSubscriber
ikq Jun 8, 2021
c82707a
removed non ascii comment
ikq Jun 8, 2021
be3c82c
subscriber: event pending
ikq Jun 9, 2021
6347ede
using Dialog in subscriber
ikq Jun 24, 2021
f234314
subscriber dialog.sendRequest added event handlers
ikq Jun 24, 2021
4a551ee
fixed: sendRequest handler names
ikq Jun 24, 2021
7c1171b
use dialog in notifier
ikq Jun 24, 2021
7559919
updated jssip.js and jssip.min.js to make push request looks better
ikq Jun 24, 2021
ff125ec
minor code improvement
ikq Jun 26, 2021
5134893
updates jssip from master
ikq Jul 4, 2021
7cfdc7e
fixed: init subscribe non-ok response no emit terminated
ikq Jul 5, 2021
864cff4
equeue subscribe until init subscribe ok
ikq Jul 6, 2021
d12ab9e
use logger instead debug, debugerror
ikq Aug 8, 2021
aa740e5
Merge remote-tracking branch 'origin/master' into subscribe_support
ikq Aug 8, 2021
f303148
subscriber/notifer set contact as ua._contact.toString()
ikq Sep 23, 2021
6f30417
added unit test subscriber/notifier communiction
ikq Sep 25, 2021
642d500
added unit test subscriber/notifier communiction
ikq Sep 25, 2021
4571e68
Merge branch 'subscribe_support' of https://github.com/ikq/JsSIP into…
ikq Sep 25, 2021
1e565a4
unit test improvement: eventSequence checking
ikq Sep 26, 2021
2775008
unit test improvement: check url, method, contact, accept, subscripti…
ikq Sep 27, 2021
8cfc574
fixed typo issues
ikq Sep 27, 2021
5262d48
Update lib/Subscriber.js
ikq Oct 5, 2021
ecdc2ae
Update lib/Notifier.js
ikq Oct 5, 2021
7c9e97c
some of the changes after the review
ikq Oct 5, 2021
2d32667
modified terminate()
ikq Oct 6, 2021
fc88e8d
fixed typo in comment
ikq Oct 6, 2021
ad37497
fixed ts constant definition
ikq Dec 8, 2021
759d40e
fixed ts definitions
ikq Sep 4, 2022
6425bcf
Merge branch 'master' into subscribe_support
ikq Jan 15, 2023
95a2325
removed spaces before EOL. Synchronized with latest master
ikq Nov 3, 2023
aac7d1c
added _notify() that called from notify() and terminate()
ikq Nov 5, 2023
eca25f7
Fixed SUBSCRIPTION_EXPIRED termination functionality
ikq Nov 5, 2023
b2ef69c
Added reason 'timeout' to user final NOTIFY
ikq Nov 5, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ module.exports =
'no-sparse-arrays': 2,
'no-this-before-super': 2,
'no-throw-literal': 2,
'no-trailing-spaces': 2,
'no-undef': 2,
'no-unexpected-multiline': 2,
'no-unmodified-loop-condition': 2,
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,17 @@ CHANGELOG

### NEXT RELEASE

* New UA config param register_from_tag_trail (#793). Credits to @kkozlik.


### 3.10.1

* TS: fix socket/transport types (#790).
* Transport: Handle keep alive request from server (#791).
* Prevent repeated ICE finish (#800). Credits to @pschichtel .
* Use built-in MediaStreamConstraints type (#809). Credits to @edumt.
* Add extra_headers as a modificable property (#825). Credits to @cesterlizi.
* Fix type definitions to not import Listener from events #837. Credits to @jlaine.


### 3.10.0
Expand Down
38 changes: 31 additions & 7 deletions dist/jssip.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* JsSIP v3.10.0
* JsSIP v3.10.1
* the Javascript SIP library
* Copyright: 2012-2022
* Copyright: 2012-2023
* Homepage: https://jssip.net
* License: MIT
*/
Expand Down Expand Up @@ -19049,6 +19049,10 @@ module.exports = /*#__PURE__*/function (_EventEmitter) {
_this13._iceReady = false;

var ready = function ready() {
if (finished) {
return;
}

connection.removeEventListener('icecandidate', iceCandidateListener);
connection.removeEventListener('icegatheringstatechange', iceGatheringStateListener);
finished = true;
Expand All @@ -19075,12 +19079,12 @@ module.exports = /*#__PURE__*/function (_EventEmitter) {
candidate: candidate,
ready: ready
});
} else if (!finished) {
} else {
ready();
}
});
connection.addEventListener('icegatheringstatechange', iceGatheringStateListener = function iceGatheringStateListener() {
if (connection.iceGatheringState === 'complete' && !finished) {
if (connection.iceGatheringState === 'complete') {
ready();
}
});
Expand Down Expand Up @@ -23854,7 +23858,21 @@ module.exports = /*#__PURE__*/function () {
}, {
key: "_onData",
value: function _onData(data) {
// CRLF Keep Alive response from server. Ignore it.
// CRLF Keep Alive request from server, reply.
if (data === '\r\n\r\n') {
logger.debug('received message with double-CRLF Keep Alive request');

try {
// Reply with single CRLF.
this.socket.send('\r\n');
} catch (error) {
logger.warn("error sending Keep Alive response: ".concat(error));
}

return;
} // CRLF Keep Alive response from server, ignore it.


if (data === '\r\n') {
logger.debug('received message with CRLF Keep Alive response');
return;
Expand Down Expand Up @@ -24332,6 +24350,12 @@ module.exports = /*#__PURE__*/function (_EventEmitter) {
break;
}

case 'extra_headers':
{
this._configuration.extra_headers = value;
break;
}

default:
logger.warn('set() | cannot set "%s" parameter in runtime', parameter);
return false;
Expand Down Expand Up @@ -24780,7 +24804,7 @@ module.exports = /*#__PURE__*/function (_EventEmitter) {
}
}; // Seal the configuration.

var writable_parameters = ['authorization_user', 'password', 'realm', 'ha1', 'authorization_jwt', 'display_name', 'register'];
var writable_parameters = ['authorization_user', 'password', 'realm', 'ha1', 'authorization_jwt', 'display_name', 'register', 'extra_headers'];

for (var parameter in this._configuration) {
if (Object.prototype.hasOwnProperty.call(this._configuration, parameter)) {
Expand Down Expand Up @@ -28340,7 +28364,7 @@ module.exports={
"name": "jssip",
"title": "JsSIP",
"description": "the Javascript SIP library",
"version": "3.10.0",
"version": "3.10.1",
"homepage": "https://jssip.net",
"contributors": [
"José Luis Millán <[email protected]> (https://github.com/jmillan)",
Expand Down
6 changes: 3 additions & 3 deletions dist/jssip.min.js

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ gulp.task('test', function()
'test/test-parser.js',
'test/test-properties.js',
'test/test-UA-no-WebRTC.js',
'test/test-digestAuthentication.js'
'test/test-digestAuthentication.js',
'test/test-UA-subscriber-notifier.js'
];

return gulp.src(src)
Expand Down
17 changes: 14 additions & 3 deletions lib/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ exports.settings = {
no_answer_timeout : 60,

// Registration parameters.
register : true,
register_expires : 600,
registrar_server : null,
register : true,
register_expires : 600,
register_from_tag_trail : '',
registrar_server : null,

// Connection options.
sockets : null,
Expand Down Expand Up @@ -282,6 +283,16 @@ const checks = {
}
},

register_from_tag_trail(register_from_tag_trail)
{
if (typeof register_from_tag_trail === 'function')
{
return register_from_tag_trail;
}

return String(register_from_tag_trail);
},

registrar_server(registrar_server)
{
if (!/^sip:/i.test(registrar_server))
Expand Down
2 changes: 1 addition & 1 deletion lib/Constants.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export declare enum DTMF_TRANSPORT {
}

export const REASON_PHRASE: Record<number, string>
export const ALLOWED_METHODS = 'INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO,NOTIFY'
export const ALLOWED_METHODS = 'INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO,NOTIFY,SUBSCRIBE'
export const ACCEPTED_BODY_TYPES = 'application/sdp, application/dtmf-relay'
export const MAX_FORWARDS = 69
export const SESSION_EXPIRES = 90
Expand Down
2 changes: 1 addition & 1 deletion lib/Constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ module.exports = {
606 : 'Not Acceptable'
},

ALLOWED_METHODS : 'INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO,NOTIFY',
ALLOWED_METHODS : 'INVITE,ACK,CANCEL,BYE,UPDATE,MESSAGE,OPTIONS,REFER,INFO,NOTIFY,SUBSCRIBE',
ACCEPTED_BODY_TYPES : 'application/sdp, application/dtmf-relay',
MAX_FORWARDS : 69,
SESSION_EXPIRES : 90,
Expand Down
24 changes: 24 additions & 0 deletions lib/Notifier.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import {EventEmitter} from 'events'
import {SUBSCRIBE, NOTIFY} from './Constants'
import * as Utils from './Utils'

declare enum NotifierTerminatedCode {
NOTIFY_RESPONSE_TIMEOUT = 0,
NOTIFY_TRANSPORT_ERROR = 1,
NOTIFY_NON_OK_RESPONSE = 2,
NOTIFY_FAILED_AUTHENTICATION = 3,
SEND_FINAL_NOTIFY = 4,
RECEIVE_UNSUBSCRIBE = 5,
SUBSCRIPTION_EXPIRED = 6
}

export class Notifier extends EventEmitter {
start(): void;
setActiveState(): void;
notify(body?: string): void;
terminate(body?: string, reason?: string): void;
get state(): string;
get id(): string;
static get C(): typeof NotifierTerminatedCode;
get C(): typeof NotifierTerminatedCode;
}
Loading