Skip to content

Conversation

@ikq
Copy link

@ikq ikq commented May 20, 2021

I added Subscriber.js Notifier.js to JsSIP

I tried write them according JsSIP style and lint errors.
Please take a look and let me know what needs to be fixed.

I already see that *.d.ts files are missing.

The work still in progress: I want add to SUBSCRIBE Contact +sip.instance
as you do in REGISTER

@jmillan
Copy link
Member

jmillan commented May 21, 2021

Hi @ikq,

JsSIP code must have the same style in order to make it readable and maintainable. Comments before making a deeper review:

  • Debug line as the first method call in al public method implementations.
  • New line after return.
  • New line before and after call to super().
  • First conditional in a block starts in new line and last ends in a new line.
  • Conditional blocks always contain curly brackets.
  • Comments in the line above when possible.
  • Calls to debug have usually a new line above and a new line below.

Please take a certain file (ie: RTCSession.js) as a reference and try to stick to its style.

@jmillan
Copy link
Member

jmillan commented May 25, 2021

@ikq

Thanks for the cleanup, 👍 We'll review the PR as we can.

@jmillan
Copy link
Member

jmillan commented May 27, 2021

@ikq,

Cosmetic comment, we use camelCase in API method arguments (not in 100% of the cases, I know, but we will get there). Could you please make such change?

Copy link
Member

@jmillan jmillan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've made the first review.

Please go through all the comments and modify as needed. We'll go for sencond review afterwards.

@ikq
Copy link
Author

ikq commented Jun 5, 2021

I mostly fixed the issues.

[I thought about dialog:
if you write in C++/java style, then you could add an abstract class dialog, and invite-dialog, subscriber and notifier dialogs would be his descendants.
The abstract dialog class could be something like stripped version of Dialog.js without actual method implementations]

About dialog, seems:

dialog interface:

  • id (string)
  • state (number)
  • receiveRequest receive incoming request with the id

other functionality:

  • check incoming requests
  • keep set of parameters to create outgoing request.

It's already implemented in Subscriber/Notifier.
[Not exactly as in Dialog.js, but the same functionality]

@jmillan
Copy link
Member

jmillan commented Jun 8, 2021

Hi,

Super busy lately. Will come back to this when we have some time.

@jmillan
Copy link
Member

jmillan commented Jun 22, 2021

H @ikq,

Dialog should be agnostic to the method. Why can't current Dialog implementation be used here? It has basically the sendRequest() method that you can call, and it will call the receiveRequest() method on your Subscriber/Notifier implementation.

@ikq
Copy link
Author

ikq commented Jun 22, 2021

Hmm...
I checked the Dialog.js code again.
sendRequest and receiveRequest can be used.

I just did not consider this possibility before because I found INVITE/CANCEL/ACK specific code and properties in the Dialog (e.g. subscriber used different dialog states set).

@jmillan
Copy link
Member

jmillan commented Jun 22, 2021

There is INVITE related code in Dialog because a dialog for INVITE method needs to behave in certain way, different to generic dialogs, but that's an implementation detail. Other clases should be able to create dialogs the same way RTCSession does.

@ikq
Copy link
Author

ikq commented Jun 24, 2021

Hi Jose,
Now subscriber and notifier used Dialog.js
It passed my basic testing now.

I'll continue to test next week:

  • I cannot check subscriber authentication (my sip server don't request it).
  • subscriber with some production server.
  • subscriber with notifier.

@ikq
Copy link
Author

ikq commented Jul 7, 2021

Testing of the current version has been completed successfully.
(subscribe authentication was not checked)

@ikq
Copy link
Author

ikq commented Jul 10, 2021

subscribe authentication checked using special test.
IMHO: the subscriber/notifier is ready.

@ikq ikq requested a review from jmillan August 3, 2021 15:49
@ikq
Copy link
Author

ikq commented Aug 8, 2021

I see I should change debug/debugerror to logger...

@jmillan
Copy link
Member

jmillan commented Aug 18, 2021

Hi @ikq,

We are super busy lately. Please keep using your branch and update this PR whenever you find any issue/enhancement.

Also, tests would accelerate the adoption.

@ikq
Copy link
Author

ikq commented Aug 20, 2021

I already use this code for my work and so far no problem.

Two browsers test can be taken from:
https://github.com/ikq/subscribe_notify_test

@jmillan
Copy link
Member

jmillan commented Aug 23, 2021

@ikq, more than an external test I mean tests in JsSIP as part of this PR, testing the clases created here.

@N4COM
Copy link

N4COM commented Sep 22, 2021

Hi, is there some news? I'd like to test this functionality.

@ikq
Copy link
Author

ikq commented Sep 22, 2021

Hi, is there some news? I'd like to test this functionality.

IMHO it's stable code.
[At least we use subscriber in our production, currently no issues reported]

The subscriber/notifier test can taken from https://github.com/ikq/subscribe_notify_test

@markusatm
Copy link
Contributor

Hi, is there a specific reason why Subscriber and Notifier don't use the Contact header from the UA like RTCSession does? If the user provides a custom contact_uri in the UAConfiguration he would have to manually add it as a extra header to Subscriber and Notifier again, wouldn't he?

@N4COM
Copy link

N4COM commented Sep 22, 2021

Hi, is there some news? I'd like to test this functionality.

IMHO it's stable code.
[At least we use subscriber in our production, currently no issues reported]

The subscriber/notifier test can taken from https://github.com/ikq/subscribe_notify_test

I'd like to use the official repository, so I'd like if it will be merged ASAP

@ikq
Copy link
Author

ikq commented Sep 22, 2021

Hi, is there a specific reason why Subscriber and Notifier don't use the Contact header from the UA like RTCSession does? If the user provides a custom contact_uri in the UAConfiguration he would have to manually add it as a extra header to Subscriber and Notifier again, wouldn't he?

Yes, I'm not using the Configuration.contact_uri

In fact, I was in a hurry to do this work, and did not pay attention at all to that there is such a parameter in the configuration !

Let check, how the configuration used for INVITE:

UA.js:
   this._contact = {
      pub_gruu  : null,
      temp_gruu : null,
      uri       : this._configuration.contact_uri,

RTCSession.js:
  this._contact = this._ua.contact.toString({
      anonymous,
      outbound : true
    });

Thanks.
It can be improved (use of Configuration.contact_uri)

P.S.
Usage Configuration.contact_uri will modify default SUBSCRIBE contact - will be missed "+sip.instance" (that I add to default SUBSCRIBE Contact)
User still can set "+sip.instance" to SUBSCRIBE Contact via custom Contact header.

@mitre-mgarber
Copy link

@ikq if you don't mind external contributions i'd be willing to take a swing at writing unit tests for this project's test framework

@ikq
Copy link
Author

ikq commented Sep 22, 2021

if you don't mind external contributions i'd be willing to take a swing at writing unit tests for this project's test framework

Thank you, I will gladly accept your help.

I have provided an external test for 2 browsers: one is sending an SUBSCRIBE and the other is receiving it and sending a NOTIFY.

Seems in unit test should be simulated 2 instances of JsSIP one send/other receive.
[I don't know how it can be written.
Probably instead two JsSIP instances, can be used single that send the message itself ?]
;-)

@stefang42
Copy link
Contributor

Thanks.
It can be improved (use of Configuration.contact_uri)

P.S.
Usage Configuration.contact_uri will modify default SUBSCRIBE contact - will be missed "+sip.instance" (that I add to default SUBSCRIBE Contact)
User still can set "+sip.instance" to SUBSCRIBE Contact via custom Contact header.

@ikq Is there a specific reason to use Configuration.contact_uri? Why not just do it as in RTCSession, with this._ua.contact.toString? Then it would also use the gruu if one was provided. Or am I missing something?

@ikq
Copy link
Author

ikq commented Sep 23, 2021

Thank you markusatm for founding the problem.
Thank you stefang42, I use your fix to build Contact in subscriber and notifier.

@jmillan
Copy link
Member

jmillan commented Sep 24, 2021

Hi,

Yes, in order for this PR to be merged we need tests in JsSIP project.

You don't need two JsSIP instances, just one instance and you should inject a transport that you control (a FAKE transport) that you use to send JsSIP UA SUBSCRIBE|NOTIFY messages and receive and check what comes from JsSIP.

If you need some help please let us know.

@ikq
Copy link
Author

ikq commented Sep 25, 2021

Hi,
I added nodeunit test to test subscriber notifier communication.

  1. Implemented loopSocket that send message itself, but modified Call-ID in each leg.
    (without the modification method findDialog confuses SUBSCRIBE dialog with NOTIFY dialog)

  2. subscriber and notifier run in the same JsSIP instance and send/receive SIP messages.

The test SIP sequence is:

  • SUBSCRIBE
  • SUBSCRIBE OK
  • NOTIFY
  • NOTIFY OK
  • unSUBSCRIBE (with expires 0)
  • unSUBSCRIBE OK
  • final NOTIFY (with Subscription-State: terminated)
  • final NOTIFY OK.

The unit test work silently, but if uncomment line JsSIP.debug.enable('JsSIP:*');
can be seen complete SIP communication.

SUBSCRIBE and NOTIFY headers checking:
url, method, contact, subscribe accept, notify subscription-state, content-type and body.
Checked order of event sequence.

@devoxy1
Copy link

devoxy1 commented Dec 5, 2023

Up!

@ddyner
Copy link

ddyner commented Dec 10, 2023

Hello. We also want to use this feature. Will this pull request be merged?

@jmillan
Copy link
Member

jmillan commented Dec 11, 2023

This is waiting for the docs to be generated. @ikq are you willing to create a PR for the doc? We cannot merge the feature without it.

@ikq
Copy link
Author

ikq commented Dec 11, 2023

Writing documentation is never easy for me but let's try.

How do you do this?

I have to download the zip (or git clone) from https://github.com/versatica/jssip.net,

install nanoc and modify content/documentation/api/ua.html

And then check the result using nanoc compile, nanoc view?

If the modified doc compiled, make Pull Request of https://github.com/versatica/jssip.net with

modified api/ua.html,
and created api.subscriber.html, api.notifier.html

Do I understand correctly ?

@ikq
Copy link
Author

ikq commented Dec 17, 2023

I created pull request for https://github.com/versatica/jssip.net
Please take a look.

@devoxy1
Copy link

devoxy1 commented Jan 9, 2024

@jmillan Hello! Could you please check it up? Thank you!

@jmillan
Copy link
Member

jmillan commented Jan 9, 2024

I'll review when I can. If you are in a hurry, please do use this branch freely.

@jmillan
Copy link
Member

jmillan commented Jan 9, 2024

I'll review when I can. If you are in a hurry, please do use this branch freely.

This way you will also collaborate on using, testing and reporting.

@devoxy1
Copy link

devoxy1 commented Jan 9, 2024

@jmillan We already using it this way :) but it's a bit difficult to maintain separate branch.
Anyways, thanks you!

@jmillan
Copy link
Member

jmillan commented Jan 18, 2024

I'm not forgetting about this...,

@devoxy1
Copy link

devoxy1 commented Mar 28, 2024

@jmillan Hello! Any chance you had time to review this one?
Thanks!

@orgads
Copy link

orgads commented Jul 23, 2024

@jmillan Ping?

@jmillan
Copy link
Member

jmillan commented Jul 29, 2024

For those willing to use this feature I would suggest you use this branch. I don't have at the moment the resources to re-check and merge this, so please, do use this branch for the time being.

@johnmarkovalo
Copy link

Looking forward with this merge also 👍

@Catlike14
Copy link

@jmillan ping?

@orgads orgads mentioned this pull request Aug 13, 2025
@orgads
Copy link

orgads commented Aug 13, 2025

Pushed a rebased version in #922.

lib/Notifier.js Outdated
* @param {String} body Notify body
* @param {Array<string>} extraHeaders
*/
_notify(subsStateParameters, body=null, extraHeaders=null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

private methods must appear after all public ones. Also, this could be called _sendNotify() also to dissambiguate.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

lib/Notifier.js Outdated
/**
* Private API
*/
_dialogTerminated(termination_code)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think terminate() would be a better name for this, as it is what the method does. RTCSession has the same name for such function.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see terminate() is already taken, then terminateDialog() would work.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@jmillan
Copy link
Member

jmillan commented Dec 19, 2025

@ikq thanks for the patience. I'll try 🤞 to finish the review and accept it in the following weeks. Can I ask you to not include any change in dist/ folder nor in package.json and to sync the branch with master?

registrar_server : null,
register : true,
register_expires : 600,
register_from_tag_trail : '',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything related to register_from_tag_trail does not belong to this PR. It's already in master. Please remove it.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 286 to 295
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);
},

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be removed.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 112 to 141
let fromTag = Utils.newTag();

if (this._ua.configuration.register_from_tag_trail)
{
if (typeof this._ua.configuration.register_from_tag_trail === 'function')
{
fromTag += this._ua.configuration.register_from_tag_trail();
}
else
{
fromTag += this._ua.configuration.register_from_tag_trail;
}
}

const request = new SIPMessage.OutgoingRequest(
JsSIP_C.REGISTER, this._registrar, this._ua, {
'to_uri' : this._to_uri,
'call_id' : this._call_id,
'cseq' : (this._cseq += 1)
'to_uri' : this._to_uri,
'call_id' : this._call_id,
'cseq' : (this._cseq += 1),
'from_tag' : fromTag
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be removed.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

lib/UA.d.ts Outdated
ha1?: string;
register?: boolean;
register_expires?: number;
register_from_tag_trail?: string | function() : string;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to be removed.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@jmillan
Copy link
Member

jmillan commented Dec 19, 2025

Also please do not edit CHANGELOG.md

Comment on lines 1962 to 1984
if (finished)
{
return;
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change does not belong to this PR. It's already in master. Please remove.

}

else if (!finished)
else
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change already in master, please remove.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

connection.addEventListener('icegatheringstatechange', iceGatheringStateListener = () =>
{
if ((connection.iceGatheringState === 'complete') && !finished)
if (connection.iceGatheringState === 'complete')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change already in master, please remove.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

lib/Notifier.js Outdated
/**
* Get dialog state.
*/
get state()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getters are set after constructor. Please check RTCSession.js

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@orgads
Copy link

orgads commented Dec 25, 2025

@ikq thanks for the patience. I'll try 🤞 to finish the review and accept it in the following weeks. Can I ask you to not include any change in dist/ folder nor in package.json and to sync the branch with master?

Done

@orgads
Copy link

orgads commented Dec 25, 2025

Hi @jmillan. Thanks for the review.

I work with @ikq at Audiocodes, and he agreed to let me take over this change as he has no time to address all the comments.

I pushed a new rebased revision, hopefully addressing all your comments. Please review.

@jmillan
Copy link
Member

jmillan commented Dec 25, 2025

Thanks, I'll take some time on a further, and hopefully last review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.