public class EventPackageSubscriber extends EventPackageSupport
Modifier and Type | Class and Description |
---|---|
static class |
EventPackageSubscriber.Subscription
Represents a general event package subscription in the sense of RFC 3265
"Session Initiation Protocol (SIP)-Specific Event Notification" from the
point of view of the subscriber and its signaling characteristics such as
Request URI, id tag value of its Event header, the Dialog
which has been created by the associated SUBSCRIBE request or through
which it was sent.
|
contentSubType, eventPackage, protocolProvider, subscriptionDuration, timer
Constructor and Description |
---|
EventPackageSubscriber(ProtocolProviderServiceSipImpl protocolProvider,
java.lang.String eventPackage,
int subscriptionDuration,
java.lang.String contentSubType,
TimerScheduler timer,
int refreshMargin)
Initializes a new EventPackageSubscriber instance which is
to provide subscriber support according to RFC 3265 to a specific SIP
ProtocolProviderService implementation for a specific event
package.
|
Modifier and Type | Method and Description |
---|---|
protected EventPackageSubscriber.Subscription |
getSubscription(javax.sip.address.Address toAddress,
java.lang.String eventId)
Gets the Subscription from the list of subscriptions managed by
this instance which is associated with a specific subscription
Address/Request URI and has a specific id tag in its Event
header.
|
protected EventPackageSubscriber.Subscription |
getSubscription(java.lang.String callId)
Gets the Subscription from the list of subscriptions managed by
this instance which is associated with a specific CallId.
|
void |
poll(EventPackageSubscriber.Subscription subscription)
Adds a specific Subscription to the list of subscriptions
managed by this instance only if another Subscription with the
same subscription Address/Request URI and id tag of its
associated Event header does not exist in the list.
|
protected void |
populateSubscribeRequest(javax.sip.message.Request req,
EventPackageSubscriber.Subscription subscription,
int expires)
Populates a specific Request instance with the headers
common to dialog-creating Requests and ones sent inside
existing dialogs and specific to the general event package subscription
functionality that this instance and a specific Subscription
represent.
|
boolean |
processRequest(javax.sip.RequestEvent requestEvent)
Implements
MethodProcessor.processRequest(RequestEvent) . |
boolean |
processResponse(javax.sip.ResponseEvent responseEvent)
Implements
MethodProcessor.processResponse(ResponseEvent) . |
boolean |
processTimeout(javax.sip.TimeoutEvent timeoutEvent)
If we got timeout we there is a problem with the connection, lets
inform the provider.
|
void |
subscribe(EventPackageSubscriber.Subscription subscription)
Creates and sends a SUBSCRIBE request to the subscription
Address/Request URI of a specific Subscription
in order to request receiving event notifications and adds the specified
Subscription to the list of subscriptions managed by this
instance.
|
void |
unsubscribe(javax.sip.address.Address toAddress,
boolean assertSubscribed)
Creates and sends a SUBSCRIBE request to a specific subscription
Address/Request URI if it matches a
Subscription with an id tag of its Event header of
null in the list of subscriptions managed by this instance with
an Expires header value of zero in order to terminate receiving event
notifications and removes the specified Subscription from
the list of subscriptions managed by this instance.
|
void |
unsubscribe(javax.sip.address.Address toAddress,
java.lang.String eventId,
boolean assertSubscribed)
Creates and sends a SUBSCRIBE request to a specific subscription
Address/Request URI if it matches a
Subscription with an id tag of its Event header of a
specific value in the list of subscriptions managed by this instance with
an Expires header value of zero in order to terminate receiving event
notifications and removes the specified Subscription from
the list of subscriptions managed by this instance.
|
addSubscription, getEventPackage, getOrCreateServerTransaction, getSubscriptions, processAuthenticationChallenge, processAuthenticationChallenge, removeSubscription, removeSubscription, removeSubscription, sendNotImplementedResponse
processDialogTerminated, processIOException, processTransactionTerminated
public EventPackageSubscriber(ProtocolProviderServiceSipImpl protocolProvider, java.lang.String eventPackage, int subscriptionDuration, java.lang.String contentSubType, TimerScheduler timer, int refreshMargin)
protocolProvider
- the SIP ProtocolProviderService implementation
for which the new instance is to provide subscriber support
for a specific event packageeventPackage
- the name of the event package the new instance is to implement
and carry in the Event and Allow-Events headerssubscriptionDuration
- the duration of each subscription to be managed by the new
instance and to be carried in the Expires headerscontentSubType
- the sub-type of the content type of the NOTIFY bodies to be
announced, expected and supported by the subscriptions to be
managed by the new instancetimer
- the Timer support which is to refresh the
subscriptions to be managed by the new instancerefreshMargin
- the number of seconds before a subscription to be managed by
the new instance expires that the new instance should attempt
to refresh itprotected EventPackageSubscriber.Subscription getSubscription(javax.sip.address.Address toAddress, java.lang.String eventId)
getSubscription
in class EventPackageSupport
toAddress
- the subscription Address/Request URI of the
Subscription to be retrievedeventId
- the id tag placed in the Event header of the
Subscription to be retrieved if there is one or null if
the Subscription should have no id tag in its Event headerprotected EventPackageSubscriber.Subscription getSubscription(java.lang.String callId)
getSubscription
in class EventPackageSupport
callId
- the CallId associated with the Subscription to be
retrievedpublic void poll(EventPackageSubscriber.Subscription subscription) throws OperationFailedException
subscription
- the new Subscription to be added to the list
of subscriptions managed by this instance if there is no other
Subscription in the list which has the same subscription
Address/Request URI and id tag of its Event headerOperationFailedException
- if we fail constructing or sending the
subscription requestprotected void populateSubscribeRequest(javax.sip.message.Request req, EventPackageSubscriber.Subscription subscription, int expires) throws OperationFailedException
req
- the Request instance to be populated with common
headers and ones specific to the event package of a specific
Subscriptionsubscription
- the Subscription which is to be described in the
specified Request i.e. its properties are to be
used to populate the specified Requestexpires
- the subscription duration to be set into the Expires header of
the specified SUBSCRIBE RequestOperationFailedException
- if we fail parsing or populating the
subscription request.public boolean processRequest(javax.sip.RequestEvent requestEvent)
MethodProcessor.processRequest(RequestEvent)
. Handles
only NOTIFY requests because they are the only requests concerning event
package subscribers and if the processing of a given request requires
event package-specific handling, delivers the request to the matching
Subscription instance. Examples of such event package-specific handling
include handling the termination of an existing Subscription and
processing the bodies of the NOTIFY requests for active Subscriptions.processRequest
in interface MethodProcessor
processRequest
in class MethodProcessorAdapter
requestEvent
- a RequestEvent specifying the SIP
Request to be processedpublic boolean processResponse(javax.sip.ResponseEvent responseEvent)
MethodProcessor.processResponse(ResponseEvent)
.
Handles only responses to SUBSCRIBE requests because they are the only
requests concerning event package subscribers (and the only requests sent
by them, for that matter) and if the processing of a given response
requires event package-specific handling, delivers the response to the
matching Subscription instance. Examples of such event
package-specific handling include letting the respective
Subscription handle the success or failure in the establishment
of a subscription.processResponse
in interface MethodProcessor
processResponse
in class MethodProcessorAdapter
responseEvent
- a ResponseEvent specifying the SIP
Response to be processedpublic boolean processTimeout(javax.sip.TimeoutEvent timeoutEvent)
processTimeout
in interface MethodProcessor
processTimeout
in class MethodProcessorAdapter
timeoutEvent
- the timeoutEvent received indicating either the
message retransmit or transaction timed outpublic void subscribe(EventPackageSubscriber.Subscription subscription) throws OperationFailedException
subscription
- a Subscription which specifies the properties of
the SUBSCRIBE request to be created and sent, to be added to
the list of subscriptions managed by this instanceOperationFailedException
- if we fail constructing or sending the
subscription request.public void unsubscribe(javax.sip.address.Address toAddress, boolean assertSubscribed) throws java.lang.IllegalArgumentException, OperationFailedException
toAddress
- a subscription Address/Request URI which
identifies a Subscription to be removed from the
list of subscriptions managed by this instanceassertSubscribed
- true to assert if the specified subscription
Address/Request URI does not identify an existing
Subscription in the list of subscriptions managed
by this instance; false to not assert if the
mentioned condition is metjava.lang.IllegalArgumentException
- if assertSubscribed is true and
toAddress does not identify an existing
Subscription in the list of subscriptions
managed by this instanceOperationFailedException
- if we fail constructing or sending the
unSUBSCRIBE request.public void unsubscribe(javax.sip.address.Address toAddress, java.lang.String eventId, boolean assertSubscribed) throws java.lang.IllegalArgumentException, OperationFailedException
toAddress
- a subscription Address/Request URI which
identifies a Subscription to be removed from the
list of subscriptions managed by this instanceeventId
- the id tag placed in the Event header of the
Subscription to be matched if there is one or
null if the Subscription should have no
id tag in its Event headerassertSubscribed
- true to assert if the specified subscription
Address/Request URI does not identify an existing
Subscription in the list of subscriptions managed
by this instance; false to not assert if the
mentioned condition is metjava.lang.IllegalArgumentException
- if assertSubscribed is true and
toAddress and eventId do not
identify an existing Subscription in the list of
subscriptions managed by this instanceOperationFailedException
- if we fail constructing or sending the
unSUBSCRIBE request.
Jitsi, the OpenSource Java VoIP and Instant Messaging client.
Distributable under Apache license.