|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.cafesip.sipunit.SipSession
org.cafesip.sipunit.SipPhone
public class SipPhone
This class provides a test program with User Agent (UA) access to the SIP protocol in the form of a SIP phone. Using this class, a test program can simulate a SIP phone and perform operations such as registration, making an outgoing call or receiving an incoming call, and buddy list/fetch (SUBSCRIBE/NOTIFY) operations. In future, a SipPhone object can have more than one SipCall object associated with it but currently only one is supported. One buddy list is supported per SipPhone object.
A SipPhone object is created by calling SipStack.createSipPhone().
Many of the methods in this class return an object or true return value if successful. In case of an error or caller-specified timeout, a null object or a false is returned. The getErrorMessage(), getReturnCode() and getException() methods may be used for further diagnostics. The getReturnCode() method returns either the SIP response code received from the network (defined in SipResponse) or a SipUnit internal status/return code (defined in SipSession). SipUnit internal codes are in a specially designated range (SipSession.SIPUNIT_INTERNAL_RETURNCODE_MIN and upward). The information provided by the getException() method is only meaningful when the getReturnCode() method returns internal SipUnit return code EXCEPTION_ENCOUNTERED. The getErrorMessage() method returns a descriptive string indicating the cause of the problem. If an exception was involved, this string will contain the name of the Exception class and the exception message. This class has a method, format(), which can be called to obtain a human-readable string containing all of this error information.
| Field Summary | |
|---|---|
static int |
DEFAULT_SUBSCRIBE_DURATION
|
| Fields inherited from class org.cafesip.sipunit.SipSession |
|---|
ERROR_OF_UNKNOWN_ORIGIN, EXCEPTION_ENCOUNTERED, FAR_END_ERROR, INTERNAL_ERROR, INVALID_ARGUMENT, INVALID_OPERATION, INVALID_UNREGISTERED_OPERATION, MAX_FORWARDS_DEFAULT, MISSING_CREDENTIAL, NONE_YET, SIPUNIT_INTERNAL_RETURNCODE_MIN, statusCodeDescription, TIMEOUT_OCCURRED, UNSUPPORTED_URI_SCHEME |
| Method Summary | |
|---|---|
Subscription |
addBuddy(java.lang.String uri,
int duration,
long timeout)
This method is the same as addBuddy(uri, duration, eventId, timeout) except that no event "id" parameter will be included. |
Subscription |
addBuddy(java.lang.String uri,
int duration,
java.lang.String eventId,
long timeout)
This method adds a buddy to the buddy list and starts an ongoing subscription for purposes of tracking the buddy's presence information. |
Subscription |
addBuddy(java.lang.String uri,
long timeout)
This method is the same as addBuddy(uri, duration, eventId, timeout) except that the duration is defaulted to the default period defined in the event package RFC (3600 seconds) and no event "id" parameter will be included. |
Subscription |
addBuddy(java.lang.String uri,
java.lang.String eventId,
long timeout)
This method is the same as addBuddy(uri, duration, eventId, timeout) except that the duration is defaulted to the default period defined in the event package RFC (3600 seconds). |
void |
addUpdateCredential(Credential c)
This method adds a new credential to the credentials list or updates an existing credential in the list. |
void |
clearCredentials()
This method empties out the credentials list - completely - for this SipPhone. |
SipCall |
createSipCall()
This method is used to create a SipCall object for handling one leg of a call. |
void |
dispose()
This method releases all resources associated with this SipPhone. |
Subscription |
fetchPresenceInfo(java.lang.String uri,
long timeout)
This method is the same as fetchPresenceInfo(uri, eventId, timeout) except that no event "id" parameter will be included in the SUBSCRIBE message. |
Subscription |
fetchPresenceInfo(java.lang.String uri,
java.lang.String eventId,
long timeout)
This method performs a presence 'fetch' on the given user, to get a one-time report on the user's presence status and information. |
javax.sip.address.Address |
getAddress()
This method returns the user Address for this SipPhone. |
Subscription |
getBuddyInfo(java.lang.String uri)
This method returns the Subscription object representing a buddy or user whose presence information was fetched at some previous point. |
java.util.Hashtable<java.lang.String,Subscription> |
getBuddyList()
Returns a copy of the current buddy list on this SipPhone. |
SipContact |
getContactInfo()
The method getContactInfo() returns the contact information currently in effect for this user agent. |
SipContact |
getLocalContactInfo()
Deprecated. Use getContactInfo() instead of this method, the term 'local' in the method name is misleading if the SipUnit test is running behind a NAT. |
java.util.Hashtable<java.lang.String,Subscription> |
getRetiredBuddies()
Returns a copy of the list of subscriptions associated with this SipPhone which are not in the current buddy list. |
SipCall |
makeCall(java.lang.String to,
int response,
long timeout,
java.lang.String viaNonProxyRoute)
This blocking basic method is used to make an outgoing call. |
SipCall |
makeCall(java.lang.String to,
int response,
long timeout,
java.lang.String viaNonProxyRoute,
java.util.ArrayList<javax.sip.header.Header> additionalHeaders,
java.util.ArrayList<javax.sip.header.Header> replaceHeaders,
java.lang.String body)
This method is the same as the basic blocking makeCall() method except that it allows the caller to specify a message body and/or additional JAIN-SIP API message headers to add to or replace in the outbound INVITE message. |
SipCall |
makeCall(java.lang.String to,
int response,
long timeout,
java.lang.String viaNonProxyRoute,
java.lang.String body,
java.lang.String contentType,
java.lang.String contentSubType,
java.util.ArrayList<java.lang.String> additionalHeaders,
java.util.ArrayList<java.lang.String> replaceHeaders)
This method is the same as the basic blocking makeCall() method except that it allows the caller to specify a message body and/or additional message headers to add to or replace in the outbound message without requiring knowledge of the JAIN-SIP API. |
SipCall |
makeCall(java.lang.String to,
java.lang.String viaNonProxyRoute)
This nonblocking basic method is used to make an outgoing call. |
SipCall |
makeCall(java.lang.String to,
java.lang.String viaNonProxyRoute,
java.util.ArrayList<javax.sip.header.Header> additionalHeaders,
java.util.ArrayList<javax.sip.header.Header> replaceHeaders,
java.lang.String body)
This method is the same as the basic nonblocking makeCall() method except that it allows the caller to specify a message body and/or additional JAIN-SIP API message headers to add to or replace in the outbound INVITE message. |
SipCall |
makeCall(java.lang.String to,
java.lang.String viaNonProxyRoute,
java.lang.String body,
java.lang.String contentType,
java.lang.String contentSubType,
java.util.ArrayList<java.lang.String> additionalHeaders,
java.util.ArrayList<java.lang.String> replaceHeaders)
This method is the same as the basic nonblocking makeCall() method except that it allows the caller to specify a message body and/or additional message headers to add to or replace in the outbound message without requiring knowledge of the JAIN-SIP API. |
void |
processEvent(java.util.EventObject event)
For internal SipUnit use only. |
Subscription |
refreshBuddy(java.lang.String uri,
int duration,
long timeout)
This method is the same as refreshBuddy(uri, duration, eventId, timeout) except that the eventId remains unchanged from whatever it already was. |
Subscription |
refreshBuddy(java.lang.String uri,
int duration,
java.lang.String eventId,
long timeout)
This method updates the presence information of a buddy in the buddy list by initiating a SUBSCRIBE/NOTIFY sequence. |
Subscription |
refreshBuddy(java.lang.String uri,
long timeout)
This method is the same as refreshBuddy(uri, duration, eventId, timeout) except that the eventId remains unchanged from whatever it already was and the SUBSCRIBE duration sent will be however much time is left on the current subscription. |
Subscription |
refreshBuddy(java.lang.String uri,
javax.sip.message.Request req,
long timeout)
This method is the same as refreshBuddy(uri, duration, eventId, timeout) except that instead of creating the SUBSCRIBE request from parameters passed in, the provided request parameter is used for sending out the SUBSCRIBE message. |
Subscription |
refreshBuddy(java.lang.String uri,
java.lang.String eventId,
long timeout)
This method is the same as refreshBuddy(uri, duration, eventId, timeout) except that the SUBSCRIBE duration sent will be however much time is left on the current subscription. |
boolean |
register(java.lang.String contact,
int expiry)
This method is equivalent to the other register() method with no authorization parameters passed in. |
boolean |
register(java.lang.String user,
java.lang.String password,
java.lang.String contact,
int expiry,
long timeout)
This method is used to register with the SIP proxy server that was specified when this SipPhone was created. |
Subscription |
removeBuddy(java.lang.String uri,
long timeout)
This method is the same as removeBuddy(uri, eventId, timeout) except that no event "id" parameter will be included in the unSUBSCRIBE message. |
Subscription |
removeBuddy(java.lang.String uri,
javax.sip.message.Request req,
long timeout)
This method is the same as removeBuddy(uri, eventId, timeout) except that instead of creating the SUBSCRIBE request from parameters passed in, the provided request parameter is used for sending out the SUBSCRIBE message if the subscription is active. |
Subscription |
removeBuddy(java.lang.String uri,
java.lang.String eventId,
long timeout)
This method removes a buddy from the buddy list and initiates a SUBSCRIBE/NOTIFY sequence to terminate the subscription unless the subscription is already terminated. |
void |
removeCredential(Credential c)
This method removes a credential from the credentials list. |
void |
removeCredential(java.lang.String realm)
This method removes a credential from the credentials list. |
boolean |
unregister(java.lang.String contact,
long timeout)
This method performs the SIP unregistration process. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.cafesip.sipunit.SipActionObject |
|---|
format, getErrorMessage, getException, getReturnCode |
| Field Detail |
|---|
public static final int DEFAULT_SUBSCRIBE_DURATION
| Method Detail |
|---|
public boolean register(java.lang.String user,
java.lang.String password,
java.lang.String contact,
int expiry,
long timeout)
Initially, a REGISTER message is sent without any user name and password. If the server returns an OK, this method returns a true value.
If any challenge is received in response to sending the REGISTER message (response code UNAUTHORIZED or PROXY_AUTHENTICATION_REQUIRED), the SipPhone's credentials list is checked first for the corresponding realm entry. If found, the credentials list entry username and password are used to form the required authorization header for resending the REGISTER message to the server, and the authorization header is saved for later re-use. You can clear out saved authorization headers by calling the unregister() method.
If the challenging realm is not found in the SipPhone credentials list, the user parameter passed to this method is examined. If it is null, this method returns false. If it is not null, the user and password values passed in to this method are used to respond to the challenge. The credentials list is not modified by this scenario (no entry is automatically added with this user, password). Also, the authorization created for this registration is not saved for re-use on a later registration. IE, the user/password parameters are for a one-time, single-shot use only.
After responding to the challenge(s) by resending the REGISTER message, this method returns a true or false value depending on the outcome as indicated by the server.
If the contact parameter is null, user@hostname is used where hostname is the SipStack's IP address property which defaults to InetAddress.getLocalHost().getHostAddress(), and other SipStack properties also apply. Otherwise, the contact parameter given is used in the Registration message sent to the server.
If the expiry parameter is 0, the registration request never expires. Otherwise, the duration, given in seconds, is sent to server.
This method can be called repeatedly to update the expiry or to add new contacts.
This method determines the contact information for this user agent, whether the registration was successful or not. If successful, the contact information may have been updated by the server (such as the expiry time, if not specified to this method by the caller). Once this method has been called, the test program can get information about the contact for this agent by calling the *MyContact*() getter methods.
user - Optional - user name for authenticating with the server.
Required if the server issues an authentication challenge.password - Optional - used only if the server issues an authentication
challenge.contact - An URI string (ex: sip:bob@192.0.2.4), or null to use the
default contact for this user agent.expiry - Expiry time in seconds, or 0 if no registration expiry.timeout - The maximum amount of time to wait for a response, in
milliseconds. Use a value of 0 to wait indefinitely.
public boolean register(java.lang.String contact,
int expiry)
contact - An URI string (ex: sip:bob@192.0.2.4)expiry - Expiry time in seconds, or 0 if no expiry.
public boolean unregister(java.lang.String contact,
long timeout)
If the contact parameter is null, user@hostname is unregistered where hostname is obtained by calling InetAddr.getLocalHost(). Otherwise, the contact parameter value is used in the unregistration message sent to the server.
contact - The contact URI (ex: sip:bob@192.0.2.4) to unregister.timeout - The maximum amount of time to wait for a response, in
milliseconds. Use a value of 0 to wait indefinitely.
public SipCall createSipCall()
public SipCall makeCall(java.lang.String to,
int response,
long timeout,
java.lang.String viaNonProxyRoute)
Use this method when (1) you want to establish a call without worrying about the details and (2) your test program doesn't need to do anything else (ie, it can be blocked) until the response code parameter passed to this method is received from the network.
In case the first condition above is false: If you need to see the (intermediate/provisional) response messages as they come in, then use SipPhone.createSipCall() and SipCall.initiateOutgoingCall() instead of this method. If your test program can tolerate being blocked until the desired response is received, you can still use this method and later look back at all the received responses by calling SipCall.getAllReceivedResponses().
In case the second condition above is false: If your test code is handling both sides of the call, or it has to do other things while this call establishment is in progress, then this method's blocking gets in the way. In that case, use the other SipPhone.makeCall() method. It returns a SipCall object after the INVITE has been successfully sent. Then, later on you can check back with the SipCall object to see the call progress or block on the call establishment, at a more convenient time.
to - The URI string (ex: sip:bob@nist.gov) to which the call should
be directedresponse - The SipResponse status code to look for after sending the
INVITE. This method returns when that status code is received.timeout - The maximum amount of time to wait for the response, in
milliseconds. Use a value of 0 to wait indefinitely.viaNonProxyRoute - Indicates whether to route the INVITE via Proxy or some other
route. If null, route the call to the Proxy that was specified
when the SipPhone object was created
(SipStack.createSipPhone()). Else route it to the given node,
which is specified as "hostaddress:port/transport" i.e.
129.1.22.333:5060/UDP.
public SipCall makeCall(java.lang.String to,
int response,
long timeout,
java.lang.String viaNonProxyRoute,
java.lang.String body,
java.lang.String contentType,
java.lang.String contentSubType,
java.util.ArrayList<java.lang.String> additionalHeaders,
java.util.ArrayList<java.lang.String> replaceHeaders)
body - A String to be used as the body of the message. Parameters
contentType, contentSubType must both be non-null to get the
body included in the message. Use null for no body bytes.contentType - The body content type (ie, 'application' part of
'application/sdp'), required if there is to be any content
(even if body bytes length 0). Use null for no message
content.contentSubType - The body content sub-type (ie, 'sdp' part of
'application/sdp'), required if there is to be any content
(even if body bytes length 0). Use null for no message
content.additionalHeaders - ArrayList of String, each element representing a SIP message
header to add to the outbound message. Examples: "Priority:
Urgent", "Max-Forwards: 10". These headers are added to the
message after a correct message has been constructed. Note
that if you try to add a header that there is only supposed to
be one of in a message, and it's already there and only one
single value is allowed for that header, then this header
addition attempt will be ignored. Use the 'replaceHeaders'
parameter instead if you want to replace the existing header
with your own. Unpredictable results may occur if your headers
are not syntactically correct or contain nonsensical values
(the message may not pass through the local SIP stack). Use
null for no additional message headers.replaceHeaders - ArrayList of String, each element representing a SIP message
header to add to the outbound message, replacing existing
header(s) of that type if present in the message. Examples:
"Priority: Urgent", "Max-Forwards: 10". These headers are
applied to the message after a correct message has been
constructed. Unpredictable results may occur if your headers
are not syntactically correct or contain nonsensical values
(the message may not pass through the local SIP stack). Use
null for no replacement of message headers.
public SipCall makeCall(java.lang.String to,
int response,
long timeout,
java.lang.String viaNonProxyRoute,
java.util.ArrayList<javax.sip.header.Header> additionalHeaders,
java.util.ArrayList<javax.sip.header.Header> replaceHeaders,
java.lang.String body)
additionalHeaders - ArrayList of javax.sip.header.Header, each element a SIP
header to add to the outbound message. These headers are added
to the message after a correct message has been constructed.
Note that if you try to add a header that there is only
supposed to be one of in a message, and it's already there and
only one single value is allowed for that header, then this
header addition attempt will be ignored. Use the
'replaceHeaders' parameter instead if you want to replace the
existing header with your own. Use null for no additional
message headers.replaceHeaders - ArrayList of javax.sip.header.Header, each element a SIP
header to add to the outbound message, replacing existing
header(s) of that type if present in the message. These
headers are applied to the message after a correct message has
been constructed. Use null for no replacement of message
headers.body - A String to be used as the body of the message. The
additionalHeaders parameter must contain a ContentTypeHeader
for this body to be included in the message. Use null for no
body bytes.
public SipCall makeCall(java.lang.String to,
java.lang.String viaNonProxyRoute)
After calling this method, you can later call one or more of the following methods on the returned SipCall object to see what happened (each is nonblocking unless otherwise noted): isCallAnswered() - to see if the call has been answered, callTimeoutOrError() - to see if an error/timeout has occured, getReturnCode() - to see the last response code received so far, getLastReceivedResponse() - to see the details of the last response received so far, getAllReceivedResponses() - to see the details of all the responses received so far, waitForAnswer() - BLOCKING - when your test program is done with its tasks and can be blocked until OK is received - it returns immediately if OK already received, waitOutgoingCallResponse() - BLOCKING - when your test program is done with its tasks and can be blocked until the next response is received (if you are interested in something other than OK) - use this only if you know that the INVITE transaction is still up.
Call this method when (1) you want to establish a call without worrying about the details and (2) your test program needs to do other tasks after the INVITE is sent but before a final/expected response is received (ie, the calling program cannot be blocked during call establishment).
Otherwise: If you need to see or act on any of the (intermediate/provisional) response messages as they come in, use SipPhone.createSipCall() and SipCall.initiateOutgoingCall() instead of this method. If your test program doesn't need to do anything else until the call is established: use the other SipPhone.makeCall() method which conveniently blocks until the response code you specify is received from the network.
to - The URI string (ex: sip:bob@nist.gov) to which the call should
be directedviaNonProxyRoute - Indicates whether to route the INVITE via Proxy or some other
route. If null, route the call to the Proxy that was specified
when the SipPhone object was created
(SipStack.createSipPhone()). Else route it to the given node,
which is specified as "hostaddress:port/transport" i.e.
129.1.22.333:5060/UDP.
public SipCall makeCall(java.lang.String to,
java.lang.String viaNonProxyRoute,
java.util.ArrayList<javax.sip.header.Header> additionalHeaders,
java.util.ArrayList<javax.sip.header.Header> replaceHeaders,
java.lang.String body)
additionalHeaders - ArrayList of javax.sip.header.Header, each element a SIP
header to add to the outbound message. These headers are added
to the message after a correct message has been constructed.
Note that if you try to add a header that there is only
supposed to be one of in a message, and it's already there and
only one single value is allowed for that header, then this
header addition attempt will be ignored. Use the
'replaceHeaders' parameter instead if you want to replace the
existing header with your own. Use null for no additional
message headers.replaceHeaders - ArrayList of javax.sip.header.Header, each element a SIP
header to add to the outbound message, replacing existing
header(s) of that type if present in the message. These
headers are applied to the message after a correct message has
been constructed. Use null for no replacement of message
headers.body - A String to be used as the body of the message. The
additionalHeaders parameter must contain a ContentTypeHeader
for this body to be included in the message. Use null for no
body bytes.
public SipCall makeCall(java.lang.String to,
java.lang.String viaNonProxyRoute,
java.lang.String body,
java.lang.String contentType,
java.lang.String contentSubType,
java.util.ArrayList<java.lang.String> additionalHeaders,
java.util.ArrayList<java.lang.String> replaceHeaders)
body - A String to be used as the body of the message. Parameters
contentType, contentSubType must both be non-null to get the
body included in the message. Use null for no body bytes.contentType - The body content type (ie, 'application' part of
'application/sdp'), required if there is to be any content
(even if body bytes length 0). Use null for no message
content.contentSubType - The body content sub-type (ie, 'sdp' part of
'application/sdp'), required if there is to be any content
(even if body bytes length 0). Use null for no message
content.additionalHeaders - ArrayList of String, each element representing a SIP message
header to add to the outbound message. Examples: "Priority:
Urgent", "Max-Forwards: 10". These headers are added to the
message after a correct message has been constructed. Note
that if you try to add a header that there is only supposed to
be one of in a message, and it's already there and only one
single value is allowed for that header, then this header
addition attempt will be ignored. Use the 'replaceHeaders'
parameter instead if you want to replace the existing header
with your own. Unpredictable results may occur if your headers
are not syntactically correct or contain nonsensical values
(the message may not pass through the local SIP stack). Use
null for no additional message headers.replaceHeaders - ArrayList of String, each element representing a SIP message
header to add to the outbound message, replacing existing
header(s) of that type if present in the message. Examples:
"Priority: Urgent", "Max-Forwards: 10". These headers are
applied to the message after a correct message has been
constructed. Unpredictable results may occur if your headers
are not syntactically correct or contain nonsensical values
(the message may not pass through the local SIP stack). Use
null for no replacement of message headers.public void dispose()
dispose in class SipSessionSipCall.dispose()public SipContact getContactInfo()
public SipContact getLocalContactInfo()
public javax.sip.address.Address getAddress()
public void addUpdateCredential(Credential c)
c - the credential to be added/updated.public void removeCredential(Credential c)
c - the credential to be removed.public void removeCredential(java.lang.String realm)
realm - the realm associated with the credential to be removed.public void clearCredentials()
public void processEvent(java.util.EventObject event)
RequestListener
processEvent in interface RequestListenerevent - Event received.
public Subscription addBuddy(java.lang.String uri,
int duration,
java.lang.String eventId,
long timeout)
This method creates a SUBSCRIBE request message, sends it out, and waits for a response to be received. It saves the received response and checks for a "proceedable" (positive) status code value. Positive response status codes include any of the following: provisional (status / 100 == 1), UNAUTHORIZED, PROXY_AUTHENTICATION_REQUIRED, OK and ACCEPTED. Any other status code, or a response timeout or any other error, is considered fatal to the subscription.
This method blocks until one of the above outcomes is reached.
In the case of a positive response status code, this method returns a Subscription object that will represent the buddy for the life of the subscription and puts the Subscription object in this SipPhone's buddy list. You can save the returned Subscription object yourself or retrieve it anytime later by calling this SipPhone's getBuddyInfo(buddy-uri). You will use the returned Subscription object to proceed through the remainder of this SUBSCRIBE-NOTIFY sequence as well as future SUBSCRIBE-NOTIFY sequences and to find out details at any given time such as the subscription state, amount of time left on the subscription, termination reason, presence information, details of received responses and requests, etc.
In the case of a positive response status code (a non-null object is returned), you may find out more about the response that was just received by calling the Subscription methods getReturnCode() and getCurrentSubscribeResponse()/getLastReceivedResponse(). Your next step at this point will be to call the Subscription's processSubscribeResponse() method to proceed with the SUBSCRIBE processing.
In the case of a fatal outcome, no Subscription is created and null is returned. In this case, call the usual SipUnit failed-operation methods to find out what happened (ie, call this SipPhone's getErrorMessage(), getReturnCode(), and/or getException() methods). The getReturnCode() method will tell you the response status code that was received from the network (unless it is an internal SipUnit error code, see the SipSession javadoc for more on that).
uri - the URI (ie, sip:bob@nist.gov) of the buddy to be added to the
list.duration - the duration in seconds to put in the SUBSCRIBE message. If 0,
this is equivalent to a fetch except that the buddy stays in
the buddy list even though the subscription won't be active.eventId - the event "id" to use in the SUBSCRIBE message, or null for no
event "id" parameter. Whatever is indicated here will be used
subsequently (for error checking SUBSCRIBE responses and
NOTIFYs from the server as well as for sending subsequent
SUBSCRIBEs) unless changed by the caller later on another
buddy method call (refreshBuddy(), removeBuddy(), fetch,
etc.).timeout - The maximum amount of time to wait for a SUBSCRIBE response,
in milliseconds. Use a value of 0 to wait indefinitely.
public Subscription addBuddy(java.lang.String uri,
long timeout)
uri - the URI (ie, sip:bob@nist.gov) of the buddy to be added to the
list.timeout - The maximum amount of time to wait for a SUBSCRIBE response,
in milliseconds. Use a value of 0 to wait indefinitely.
public Subscription addBuddy(java.lang.String uri,
int duration,
long timeout)
uri - the URI (ie, sip:bob@nist.gov) of the buddy to be added to the
list.duration - the duration in seconds to put in the SUBSCRIBE message. If 0,
this is equivalent to a fetch except that the buddy stays in
the buddy list even though the subscription won't be active.timeout - The maximum amount of time to wait for a SUBSCRIBE response,
in milliseconds. Use a value of 0 to wait indefinitely.
public Subscription addBuddy(java.lang.String uri,
java.lang.String eventId,
long timeout)
uri - the URI (ie, sip:bob@nist.gov) of the buddy to be added to the
list.eventId - the event "id" to use in the SUBSCRIBE message, or null for no
event "id" parameter. See addBuddy(uri, duration, eventId,
timeout) javadoc for details on event "id" treatment.timeout - The maximum amount of time to wait for a SUBSCRIBE response,
in milliseconds. Use a value of 0 to wait indefinitely.
public Subscription fetchPresenceInfo(java.lang.String uri,
java.lang.String eventId,
long timeout)
This method creates a SUBSCRIBE request message with expiry time of 0, sends it out, and waits for a response to be received. It saves the received response and checks for a "proceedable" (positive) status code value. Positive response status codes include any of the following: provisional (status / 100 == 1), UNAUTHORIZED, PROXY_AUTHENTICATION_REQUIRED, OK and ACCEPTED. Any other status code, or a response timeout or any other error, is considered fatal to the operation.
This method blocks until one of the above outcomes is reached.
In the case of a positive response status code, this method returns a Subscription object representing the user and puts the Subscription object in this SipPhone's retired buddy list. The retired buddy list consists of subscriptions resulting from a fetch or from removing a buddy from the buddy list. You can save the returned Subscription object yourself or retrieve it anytime later by calling this SipPhone's getBuddyInfo(buddy-uri). You will use the returned Subscription object to proceed through the remainder of the SUBSCRIBE-NOTIFY sequence and to find out details such as the subscription state, termination reason, presence information, details of received responses and requests, etc.
In the case of a positive response status code (a non-null object is returned), you may find out more about the response that was just received by calling the Subscription methods getReturnCode() and getCurrentSubscribeResponse()/getLastReceivedResponse(). Your next step at this point will be to call the Subscription's processSubscribeResponse() method to proceed with the SUBSCRIBE processing.
In the case of a fatal outcome, no Subscription is created and null is returned. In this case, call the usual SipUnit failed-operation methods to find out what happened (ie, call this SipPhone's getErrorMessage(), getReturnCode(), and/or getException() methods). The getReturnCode() method will tell you the response status code that was received from the network (unless it is an internal SipUnit error code, see the SipSession javadoc for more on that).
uri - the URI (ie, sip:bob@nist.gov) of the user whose presence info
is to be fetched.eventId - the event "id" to use in the SUBSCRIBE message, or null for no
event "id" parameter. Whatever is indicated here will be used
subsequently, for error checking the SUBSCRIBE response and
NOTIFY from the server.timeout - The maximum amount of time to wait for a SUBSCRIBE response,
in milliseconds. Use a value of 0 to wait indefinitely.
public Subscription fetchPresenceInfo(java.lang.String uri,
long timeout)
uri - the URI (ie, sip:bob@nist.gov) of the user whose presence info
is to be fetched.timeout - The maximum amount of time to wait for a SUBSCRIBE response,
in milliseconds. Use a value of 0 to wait indefinitely.
public Subscription getBuddyInfo(java.lang.String uri)
uri - the URI (ie, sip:bob@nist.gov) of the user whose subscription
object is to be returned.
public Subscription refreshBuddy(java.lang.String uri,
int duration,
java.lang.String eventId,
long timeout)
The subscription duration is reset to the passed in value. If the passed in duration is 0, this is an unsubscribe. Note, the buddy stays in the buddy list even though the subscription won't be active.
uri - the URI (ie, sip:bob@nist.gov) of the buddy in the list to
refreshduration - the duration in seconds to put in the SUBSCRIBE message and
reset the subscription time left to.eventId - the event "id" to use in the SUBSCRIBE message, or null for no
event "id" parameter. Whatever is indicated here will be used
subsequently (for error checking SUBSCRIBE responses and
NOTIFYs from the server as well as for sending subsequent
SUBSCRIBEs) unless changed by the caller later on another
buddy method call (refreshBuddy(), removeBuddy(), fetch,
etc.).timeout - The maximum amount of time to wait for a SUBSCRIBE response,
in milliseconds. Use a value of 0 to wait indefinitely.
public Subscription refreshBuddy(java.lang.String uri,
java.lang.String eventId,
long timeout)
uri - the URI (ie, sip:bob@nist.gov) of the buddy in the list to
refresheventId - the event "id" to use in the SUBSCRIBE message, or null for no
event "id" parameter. See refreshBuddy(uri, duration, eventId,
timeout) javadoc for details on event "id" treatment.timeout - The maximum amount of time to wait for a SUBSCRIBE response,
in milliseconds. Use a value of 0 to wait indefinitely.
public Subscription refreshBuddy(java.lang.String uri,
int duration,
long timeout)
uri - the URI (ie, sip:bob@nist.gov) of the buddy in the list to
refreshduration - the duration in seconds to put in the SUBSCRIBE message and
reset the subscription time left to.timeout - The maximum amount of time to wait for a SUBSCRIBE response,
in milliseconds. Use a value of 0 to wait indefinitely.
public Subscription refreshBuddy(java.lang.String uri,
long timeout)
uri - the URI (ie, sip:bob@nist.gov) of the buddy in the list to
refreshtimeout - The maximum amount of time to wait for a SUBSCRIBE response,
in milliseconds. Use a value of 0 to wait indefinitely.
public Subscription refreshBuddy(java.lang.String uri,
javax.sip.message.Request req,
long timeout)
The Request parameter passed in comes from Subscription.createSubscribeMessage(). The subscription duration is reset to the passed in Request's expiry value. If it is 0, this is an unsubscribe. Note, the buddy stays in the buddy list even though the subscription won't be active. The event "id" in the given request will be used subsequently (for error checking SUBSCRIBE responses and NOTIFYs from the server as well as for sending subsequent SUBSCRIBEs).
uri - the URI (ie, sip:bob@nist.gov) of the buddy in the list to
refreshreq - the Request to send to the servertimeout - The maximum amount of time to wait for a SUBSCRIBE response,
in milliseconds. Use a value of 0 to wait indefinitely.
public Subscription removeBuddy(java.lang.String uri,
java.lang.String eventId,
long timeout)
If the subscription is active, this operation is virtually the same as addBuddy(uri, duration, eventId, timeout) except that it is an 'unsubscribe' and also the existing Subscription object for this buddy continues to be used (no new one is created). For a test program, stepping through and processing the SUBSCRIBE/NOTIFY sequence for a "remove" is the same as it is for the addBuddy() case. Please read the addBuddy(uri, duration, eventId, timeout) javadoc.
If the subscription is already terminated, no SUBSCRIBE/NOTIFY sequence is initiated.
In order for you to determine whether or not to proceed forward with the SUBSCRIBE/NOTIFY sequence processing when this method returns non-null, call the returned Subscription's isRemovalComplete() method. It will tell you if an unsubscribe sequence was initiated, by returning false, or not initiated, by returning true.
uri - the URI (ie, sip:bob@nist.gov) of the buddy to be removedeventId - the event "id" to use in the SUBSCRIBE message, or null for no
event "id" parameter. Whatever is indicated here will be used
subsequently, for error checking the unSUBSCRIBE response and
NOTIFY from the server.timeout - The maximum amount of time to wait for a SUBSCRIBE response,
in milliseconds. Use a value of 0 to wait indefinitely.
public Subscription removeBuddy(java.lang.String uri,
long timeout)
uri - the URI (ie, sip:bob@nist.gov) of the buddy to be removedtimeout - The maximum amount of time to wait for a SUBSCRIBE response,
in milliseconds. Use a value of 0 to wait indefinitely.
public Subscription removeBuddy(java.lang.String uri,
javax.sip.message.Request req,
long timeout)
The Request parameter passed in comes from Subscription.createSubscribeMessage(). The event "id" in the given request will be used subsequently for error checking the SUBSCRIBE response and NOTIFY request from the server.
uri - the URI (ie, sip:bob@nist.gov) of the buddy to be removedreq - the Request to send to the servertimeout - The maximum amount of time to wait for a SUBSCRIBE response,
in milliseconds. Use a value of 0 to wait indefinitely.
public java.util.Hashtable<java.lang.String,Subscription> getBuddyList()
See related methods getBuddyInfo(), getRetiredBuddies().
public java.util.Hashtable<java.lang.String,Subscription> getRetiredBuddies()
See related methods getBuddyInfo(), getBuddyList().
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||