-
Notifications
You must be signed in to change notification settings - Fork 726
Refer rewrite #459
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
Merged
Merged
Refer rewrite #459
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Create ReferServerContext - Remove "follow refer" - New events (referRequested, referAccepted, referRejected) - Remove single refer test
Resolves #89
- progress, accept, reject are all for the refer - make sendNotify public Pass referred-by header if it exists
This was referenced Oct 27, 2017
Closed
TODO: - ClientContext needs to be dialog aware - ReferClientContext should extend and use ClientContext once it is dialog aware
This reverts commit b08c39b.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 is intended to simplify the refer handling and address all of the issues under the refer refactor milestone. This documentation looks daunting, but it is a lot of different documentation for Refer handling. Most of this is not needed for the majority of use cases that people are using. It should be in a stable state, and merging this will cause the release of 0.9.0 as it is API breaking.
Documentation
Sending a refer
Sending a refer is mostly the same. You can call refer on any active session and it will send a refer. Refer takes a single argument options. When you call
referon the session aReferClientContextwill be created. The only function that can be called on aReferClientContextisreferwhich will be called automatically on the session. You only need to callrefermanually if you are sending an out of dialog refer.refer(target, options)targetThis is the target of the refer. It can be a
Stringor a session (InviteClientContextorInviteServerContext). If it is aStringa blind transfer will be sent (Refer without replaces). If it is a session then an attended transfer will occur (Refer with replaces)optionsextraHeaders-Arrayof extra headers to use in the refer request.receiveResponse-Functionthat will be called with the response of the refer after SIP.js does it's internal processing.activeAfterTransfer-booleaniftrue, when the refer is successful it will not automatically terminate the applicant session. Default:false.ReferClientContextAdvanced Topic
To send an out of dialog refer you need to create a
ReferClientContextthen call thereferfunction.Constructor
var rcc = new SIP.ReferClientContext(ua, applicant, target, options);uaA valid UA to be used to send the refer with. See UA documentation.
applicantWho is sending the refer. If this is an in dialog refer, the applicant is the currently active session. If this is an out of dialog refer, the applicant must have a
contactfield indicating the contact to use for the refer and must have asendRequestfunction which will be used to send the request. In most cases, this should simply turn around and call theUA.requestfunction with the appropriate headers etc.targetSee documentation above.
optionsSee documentation above
Methods
refer(options)Send the actual refer. See above for documentation of options.
Receiving a refer
If you do nothing and receive a valid refer, SIP.js will automatically follow the refer
Receiving a refer is all new. No longer do you need to set up a listener and follow the refer yourself. If you would like more granular control, add a listener for the
referRequestedevent on yoursession. This will give you a handle to theReferServerContextReferServerContextConstructor
var rsc = new SIP.ReferServerContext(ua, request)uaA valid ua that the refer request was received on. See UA documentation for more.
requestThe SIP request of the REFER.
Methods
progress()Send a 100 progress method to the REFER.
accept(options, modifiers)Accept the refer. Sends a 202 Accepted.
The
optionsobject defines some additional options that you can use. Ifoptions.followReferis truthy, then SIP.js will try and follow the refer on its own.options.inviteOptionsare a set of options to pass toUA.invite(options).options.extraHeadersis an array of extra headers to use.The
modifiersarray are standard modifiers to use on aninvitefor the new session.reject()Reject the refer.
sendNotify(body)Used to send
Notifymessages about the status of the new SIP session to the referrer.The
bodymust be a validsipfrag.Events
All of the events emit with the
ReferContextthat they are using. All of the events are emitted on theReferContextand applicantsessionunless otherwise noted.referRequestedWe have sent or received a refer.
outOfDialogReferRequestedEmitted on the
UAonly.An out of dialog refer has been received. The UA option
allowOutOfDialogRefersmust be set to true.referRequestAcceptedThe request to do a refer was accepted. The endpoint is now attempting to do the refer.
referInviteSentOnly emitted on the
ReferServerContextwhen theinvitefor the new SIP session is sent.Following events indicate the progress of the new session
referProgressThe new session has transitioned into the progress state
referAcceptedThe new session is set up successfully
referRejectedThe new session did not set up correctly, and the old session should be resumed
UA Options
allowOutOfDialogReferSECURITY WARNING! If enabled a malicious endpoint could take control of your client
Default:
falseThis will enable you to receive refers out of any dialogs. Only enable if you have an
outOfDialogReferRequestedevent listener on your UA. If there is no event listener the default behavior of SIP.js is to try and follow these Refer's.