|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.cafesip.sipunit.PresenceNotifySender
public class PresenceNotifySender
The primary purpose of this class is as a test utility, to verify other UA's NOTIFY reception processing. When instantiated, an object of this class listens for a SUBSCRIBE message. After the calling program has sent a SUBSCRIBE message to this object's uri, it can call this object's processSubscribe() to receive and process the SUBSCRIBE and send a response. After that, this object sends a NOTIFY message on that subscription each time method sendNotify() is called, with the given content body. This class can listen for and show the response to a given sent NOTIFY message. It can receive and process multiple SUBSCRIBE messages for a subscription.
| Constructor Summary | |
|---|---|
PresenceNotifySender(SipPhone userb)
A constructor for this class. |
|
| Method Summary | |
|---|---|
javax.sip.message.Request |
addNotifyHeaders(javax.sip.message.Request req,
java.lang.String toUser,
java.lang.String toDomain,
java.lang.String subscriptionState,
java.lang.String termReason,
java.lang.String body,
int timeLeft)
This method adds each of the given parameters, if not null, to the given NOTIFY Request parameter which just contains the request line (created from a string). |
void |
dispose()
Dispose of this object (but not the stack given to it). |
java.util.ArrayList<SipRequest> |
getAllReceivedRequests()
This method returns all the requests received by this object and can be called directly by a test program. |
java.util.ArrayList<SipResponse> |
getAllReceivedResponses()
This method returns all the responses received by this object and can be called directly by a test program. |
javax.sip.Dialog |
getDialog()
|
java.lang.String |
getErrorMessage()
Returns the error message, if any, associated with the last operation. |
SipRequest |
getLastReceivedRequest()
This method returns the last request received by this object and can be called directly by a test program. |
SipResponse |
getLastReceivedResponse()
This method returns the last response received by this object and can be called directly by a test program. |
javax.sip.message.Request |
getLastSentNotify()
Returns the NOTIFY request that was last sent, or null if none has ever been sent. |
boolean |
needAuthorization(javax.sip.ResponseEvent event)
Called to find out if a sent NOTIFY was challenged. |
void |
processEvent(java.util.EventObject event)
For internal SipUnit use only. |
boolean |
processSubscribe()
This method waits for up to 10 seconds to receive a SUBSCRIBE and if received, it sends an OK response. |
boolean |
processSubscribe(long timeout,
int statusCode,
java.lang.String reasonPhrase)
This method starts a thread that waits for up to 'timeout' milliseconds to receive a SUBSCRIBE and if received, it sends a response with 'statusCode' and 'reasonPhrase' (if not null). |
boolean |
processSubscribe(long timeout,
int statusCode,
java.lang.String reasonPhrase,
int overrideDuration,
javax.sip.header.EventHeader overrideEvent)
Same as the other processSubscribe() except allows for a couple of overrides for testing error handling by the far end outbound SUBSCRIBE side: (a) this method takes a duration for overriding what would normally/correctly be sent back in the response (which is the same as what was received in the SUBSCRIBE request or default 3600 if none was received). |
boolean |
register(Credential credential)
This method registers this notify sender as a UA with the proxy/registrar used to create the SipPhone passed to this object's contructor. |
SipTransaction |
resendWithAuthorization(javax.sip.ResponseEvent event)
This method resends a NOTIFY statefully and with required authorization headers. |
boolean |
sendNotify(javax.sip.message.Request req,
boolean viaProxy)
This method sends the given request to the subscriber. |
boolean |
sendNotify(java.lang.String subscriptionState,
java.lang.String termReason,
java.lang.String body,
int timeLeft,
boolean viaProxy)
This method creates a NOTIFY message using the given parameters and sends it to the subscriber. |
boolean |
sendNotify(java.lang.String subscriptionState,
java.lang.String termReason,
java.lang.String body,
int timeLeft,
javax.sip.header.EventHeader eventHdr,
javax.sip.header.SubscriptionStateHeader ssHdr,
javax.sip.header.AcceptHeader accHdr,
javax.sip.header.ContentTypeHeader ctHdr,
boolean viaProxy)
This method creates a NOTIFY message using the given parameters and sends it to the subscriber. |
SipTransaction |
sendStatefulNotify(javax.sip.message.Request req,
boolean viaProxy)
This method sends the given request to the subscriber. |
void |
setDialog(javax.sip.Dialog dialog)
|
java.util.EventObject |
waitResponse(SipTransaction trans,
long timeout)
The waitResponse() method waits for a response to a previously sent transactional request message. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public PresenceNotifySender(SipPhone userb)
userb - SipPhone object to use for messaging.
java.lang.Exception - If there's a problem| Method Detail |
|---|
public void dispose()
public boolean processSubscribe()
public boolean processSubscribe(long timeout,
int statusCode,
java.lang.String reasonPhrase)
timeout - - number of milliseconds to wait for the SUBSCRIBEstatusCode - - use in the response to the SUBSCRIBEreasonPhrase - - if not null, use in the SUBSCRIBE response
public boolean processSubscribe(long timeout,
int statusCode,
java.lang.String reasonPhrase,
int overrideDuration,
javax.sip.header.EventHeader overrideEvent)
public boolean sendNotify(java.lang.String subscriptionState,
java.lang.String termReason,
java.lang.String body,
int timeLeft,
boolean viaProxy)
subscriptionState - - String to use as the subscription state.termReason - - used only when subscriptionState = TERMINATED.body - - NOTIFY body to put in the messagetimeLeft - - expiry in seconds to put in the NOTIFY message (used only
when subscriptionState = ACTIVE or PENDING).viaProxy - If true, send the message to the proxy. In this case a Route
header will be added. Else send the message as is.
public boolean sendNotify(java.lang.String subscriptionState,
java.lang.String termReason,
java.lang.String body,
int timeLeft,
javax.sip.header.EventHeader eventHdr,
javax.sip.header.SubscriptionStateHeader ssHdr,
javax.sip.header.AcceptHeader accHdr,
javax.sip.header.ContentTypeHeader ctHdr,
boolean viaProxy)
subscriptionState - - String to use as the subscription state. Overridden by
sshdr.termReason - - used only when subscriptionState = TERMINATED. Overridden by
sshdr.body - - NOTIFY body to put in the messagetimeLeft - - expiry in seconds to put in the NOTIFY subscription state
header (only when subscriptionState = ACTIVE or PENDING),
unless the timeLeft value is -1 in which case don't include
expires information in the subscription state header.
Overridden by sshdr.eventHdr - - if not null, use this event header in the NOTIFY messagessHdr - - if not null, use this subscription state header in the
NOTIFY message instead of building one from other parameters
given.accHdr - - if not null, use this accept header. Otherwise build the
default package one (pidf+xml).ctHdr - - if not null, use this content type header. Otherwise build
the default package one (pidf+xml).viaProxy - If true, send the message to the proxy. In this case a Route
header will be added. Else send the message as is.
public javax.sip.message.Request addNotifyHeaders(javax.sip.message.Request req,
java.lang.String toUser,
java.lang.String toDomain,
java.lang.String subscriptionState,
java.lang.String termReason,
java.lang.String body,
int timeLeft)
req - Request parameter which just contains the request linetoUser - Used to create the 'To' header address - user parttoDomain - Used to create the 'To' header address - host part of sip URIsubscriptionState - active, pending, or terminated (SubscriptionStateHeader
constant)termReason - any stringbody - the entire content as a stringtimeLeft - number of seconds to put in the NOTIFY
public boolean sendNotify(javax.sip.message.Request req,
boolean viaProxy)
req - javax.sip.message.Request to send.viaProxy - If true, send the message to the proxy. In this case a Route
header will be added. Else send the message as is.
public SipTransaction sendStatefulNotify(javax.sip.message.Request req,
boolean viaProxy)
req - javax.sip.message.Request to send.viaProxy - If true, send the message to the proxy. In this case a Route
header will be added. Else send the message as is.
public java.util.EventObject waitResponse(SipTransaction trans,
long timeout)
trans - The SipTransaction object associated with the sent request.
This is the object returned by sendStatefulNotify().timeout - The maximum amount of time to wait, in milliseconds. Use a
value of 0 to wait indefinitely.
public boolean register(Credential credential)
credential - authentication information matching that at the server
public java.lang.String getErrorMessage()
public javax.sip.message.Request getLastSentNotify()
public java.util.ArrayList<SipResponse> getAllReceivedResponses()
MessageListener
getAllReceivedResponses in interface MessageListenerMessageListener.getLastReceivedResponse()public java.util.ArrayList<SipRequest> getAllReceivedRequests()
MessageListener
getAllReceivedRequests in interface MessageListenerMessageListener.getLastReceivedRequest()public SipRequest getLastReceivedRequest()
MessageListener
getLastReceivedRequest in interface MessageListenerMessageListener.getAllReceivedRequests()public SipResponse getLastReceivedResponse()
MessageListener
getLastReceivedResponse in interface MessageListenerMessageListener.getAllReceivedResponses()public void processEvent(java.util.EventObject event)
RequestListener
processEvent in interface RequestListenerevent - Event received.public boolean needAuthorization(javax.sip.ResponseEvent event)
event - object returned by waitResponse().
public SipTransaction resendWithAuthorization(javax.sip.ResponseEvent event)
event - object returned by waitResponse()
public javax.sip.Dialog getDialog()
public void setDialog(javax.sip.Dialog dialog)
dialog - The dialog to set.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||