Support for SIP SUBSCRIBE/NOTIFY in SIP plugin #1768
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request is part of a series of efforts aimed at improving the current state of the SIP plugin. In the next few weeks we'll publish more, as they're currently still in a testing phase and sharing them now would probably cause more noise than help. These new developments have been sponsored by a Colombian Company with 21 years of experience on developing Telecommunication Solutions.
As the title says, this branch implements support for SIP SUBSCRIBE, and the management of related SIP NOTIFY events. The syntax is relatively simple, and looks like this:
The only mandatory property is the
event
to subscribe to; what to put in theAccept
header is optional, and if you don't specify ato
we'll send the SUBSCRIBE to the user's identity (default behaviour).The plugin doesn't care about the specific nature of the events, so the feature can be used for everything that works with SUBSCRIBE and NOTIFY. Here's a snippet of how that works with MWI:
Request:
Events:
Basically, when you subscribe you'll first get an event telling you we're going to send the SUBSCRIBE; then an event telling you if the SUBSCRIBE indeed succeeded; events after that will include the content of the NOTIFY messages (in this case, I didn't have any messages
waiting in my Asterisk setup).
Unsubscribing is just as easy:
Events:
After that, no events for that package will be handled anymore.
As I was saying, the mechanism is flexible, so it can be used for different kind of subscriptions as well. This is how you'd subscribe to events from the conferencing package, for instance:
To facilitate the integration with the conferencing package, we now detect the "isfocus" attribute as well, when available in the Contact header of an incoming INVITE or 200 OK. When it's there, we add an
isfocus:true
attribute in the call-related event: this way, you can use that as a trigger to, e.g., subscribe to theconference-info
events whenisfocus
is there. Anyway, I never tested this so you may want to confirm it works as expected.This should be all. From a few tests this seems to be working as expected, but I didn't test extensively, mostly because I don't have a complete SIP setup to play with. Please test and provide feedback.