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

Add support for multiple request matching strategies when processing NOTIFY requests #24

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

teles-mami
Copy link

@teles-mami teles-mami commented Jan 16, 2018

The SipPhone class has a specific flow for processing NOTIFY requests:

validate request -> process if event is (conference | refer | presence | send bad request) -> else orphaned event error (call or transaction does not exist).

This flow is hard to intercept and extend via inheritance without actually copy-pasting code from the SipPhone itself. In order to avoid cumbersome inheritance of SipPhone for NOTIFY request processing, we introduce the conctept of executable NOTIFY processing strategies, which will determine if a request belongs to one of the registered EventSubscriber classes (which are not so difficultly inherited).

Thus we take inspiration from the request handling strategy solution and introduce strategies which will allow to further the spectrum of event packages which the SipPhone supports.

This pull request does NOT provide extended set of event packages, and does not address the issue of coupling of EventSubscriber with the SipPhone parent. It is a prelude and a gateway to the end user/tester to provide their own solutions and customized event handling without actually inheriting the SipPhone itself.

Related issue

This commit introduces a concept of a request processing strategy, which is evaluated against the incoming request. This (collection of) strateg(y/ies) provides a determination mechanism of a request being processed by a SipSession or its children. Thus a user may provide extensions to the SipSession on which inbound requests may be accepted without the need to mutate any parameters, or request event processing mechanisms in SipPhone

This is a derivation of the request matcher, allowing for a more flexible implementation.
In order to support extensible request handling, we introduce the RequestProcessor class, which is tasked with executing a sequence of strategies over an inbound request for a SipListener instance. These strategies execute sequentially until one of the strategies accepts the request. If no strategies were executed or the validation fails, the governing SipPhone will return an appropriate error (which indicates that either the event was not recognized or the subscription was orphaned).
@teles-mami teles-mami changed the title Feature/event handler strategy Add support for multiple request matching strategies when processing NOTIFY requests Jan 16, 2018
@gsaslis
Copy link
Contributor

gsaslis commented Jan 24, 2018

@jaimecasero this one is also up for review ;)

*
* @see RequestProcessor
*/
public class RequestProcessingResult {
Copy link
Author

Choose a reason for hiding this comment

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

Thinking about converting this to an enum, because the double boolean tautology may confuse the implementing user of the strategies

Copy link
Contributor

Choose a reason for hiding this comment

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

@teles-mami makes sense

Copy link
Author

Choose a reason for hiding this comment

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

After further analysis, we will need this form for the event processing logic.

Specifically in "presence" event processing, we will have successful (orphaned) events which will be processed later on, but not in the current handler.

Leaving the logic as-is.

@gsaslis gsaslis requested review from a team and removed request for jaimecasero February 27, 2018 13:24
@teles-mami
Copy link
Author

Also like the other PR,
any news on the validity of this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants