|
|||||||||
| 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, buddy list/fetch (SUBSCRIBE/NOTIFY) operations, call refer, etc. In future, a SipPhone object can have more than one SipCall object associated with it but currently only one is supported. Multiple subscriptions (buddy/presence, refer) are 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 | |
|---|---|
PresenceSubscriber |
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. |
PresenceSubscriber |
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. |
PresenceSubscriber |
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. |
PresenceSubscriber |
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. |
PresenceSubscriber |
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. |
PresenceSubscriber |
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. |
PresenceSubscriber |
getBuddyInfo(java.lang.String uri)
This method returns the PresenceSubscriber object representing a buddy or user whose presence information was fetched at some previous point. |
java.util.Hashtable<java.lang.String,PresenceSubscriber> |
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.List<ReferSubscriber> |
getRefererInfo(javax.sip.address.SipURI referToUri)
This method returns the subscription object(s) associated with the given referToUri. |
java.util.List<ReferSubscriber> |
getRefererInfoByDialog(java.lang.String dialogId)
This method returns the subscription object(s) associated with the given dialog ID. |
java.util.List<ReferSubscriber> |
getRefererList()
Returns a copy of the list of subscriptions associated with outbound REFER requests from this SipPhone. |
java.util.Hashtable<java.lang.String,PresenceSubscriber> |
getRetiredBuddies()
Returns a copy of the list of subscriptions associated with this SipPhone which are not in the current buddy list. |
javax.sip.address.SipURI |
getUri(java.lang.String scheme,
java.lang.String userHostPort,
java.lang.String transportUriParameter,
java.lang.String methodUriParameter,
java.util.Map<java.lang.String,java.lang.String> otherUriParameters,
java.lang.String joinUriHeader,
java.lang.String replacesUriHeader,
java.lang.String bodyUriHeader,
java.util.Map<java.lang.String,java.lang.String> otherUriHeaders)
Creates an URI object useful for passing into methods such as SipPhone.refer(). |
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. |
javax.sip.message.Request |
processAuthChallenge(javax.sip.message.Response response,
javax.sip.message.Request req_msg)
This method is the same as the other processAuthChallenge() without the user/password option. |
javax.sip.message.Request |
processAuthChallenge(javax.sip.message.Response response,
javax.sip.message.Request req_msg,
java.lang.String username,
java.lang.String password)
This method is public for test purposes and for use when using low level SipSession methods for sending/receiving messages. |
void |
processEvent(java.util.EventObject event)
For internal SipUnit use only. |
ReferSubscriber |
refer(javax.sip.Dialog dialog,
javax.sip.address.SipURI referToUri,
java.lang.String eventId,
long timeout)
This basic refer method creates an in-dialog REFER request message, sends it out, and waits for a first response to be received. |
ReferSubscriber |
refer(javax.sip.Dialog dialog,
javax.sip.address.SipURI referToUri,
java.lang.String eventId,
long timeout,
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 in-dialog refer() 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 message. |
ReferSubscriber |
refer(javax.sip.Dialog dialog,
javax.sip.address.SipURI referToUri,
java.lang.String eventId,
long timeout,
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 in-dialog refer() 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. |
ReferSubscriber |
refer(java.lang.String refereeUri,
javax.sip.address.SipURI referToUri,
java.lang.String eventId,
long timeout,
java.lang.String viaNonProxyRoute)
This basic refer method creates an out-of-dialog REFER request message, sends it out, and waits for a first response to be received. |
ReferSubscriber |
refer(java.lang.String refereeUri,
javax.sip.address.SipURI referToUri,
java.lang.String eventId,
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 out-of-dialog refer() 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 message. |
ReferSubscriber |
refer(java.lang.String refereeUri,
javax.sip.address.SipURI referToUri,
java.lang.String eventId,
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 out-of-dialog refer() 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. |
boolean |
register(javax.sip.address.SipURI requestUri,
java.lang.String user,
java.lang.String password,
java.lang.String contact,
int expiry,
long timeout)
This method is the same as the register(String user, String password, String contact, int expiry, long timeout) method except for the Request-URI used in the outgoing REGISTER method. |
boolean |
register(java.lang.String contact,
int expiry)
This method is equivalent to the register(String user, String password, String contact, int expiry, long timeout) method except with no authorization parameters specified. |
boolean |
register(java.lang.String user,
java.lang.String password,
java.lang.String contact,
int expiry,
long timeout)
This method is used for SIP registration. |
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(javax.sip.address.SipURI requestUri,
java.lang.String user,
java.lang.String password,
java.lang.String contact,
int expiry,
long timeout)
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 javax.sip.message.Request processAuthChallenge(javax.sip.message.Response response,
javax.sip.message.Request req_msg,
java.lang.String username,
java.lang.String password)
For each received challenge present in the response message: SipPhone's credentials list is checked first, for the realm entry. If it is not found there, the username parameter passed into this method is checked. If null, this method returns null. If not null, the passed in username and password values are used to respond to the received challenge. In this case an entry is NOT added to the credentials list associating these values with the challenging realm and the authorization created here is NOT saved for later re-use. If the credentials list contains an entry for the challenging realm, then the authorization created here is saved in the authorizations list for later re-use.
response - the challenge that was receivedreq_msg - the request originally sent (that was challenged)username - see abovepassword - see above
public javax.sip.message.Request processAuthChallenge(javax.sip.message.Response response,
javax.sip.message.Request req_msg)
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 PresenceSubscriber 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 PresenceSubscriber object that will represent the buddy for the life of the subscription and puts the PresenceSubscriber object in this SipPhone's buddy list. You can save the returned PresenceSubscriber object yourself or retrieve it anytime later by calling this SipPhone's getBuddyInfo(buddy-uri). Use the returned PresenceSubscriber object to proceed through the remainder of this SUBSCRIBE-NOTIFY sequence as well as for 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 PresenceSubscriber methods getReturnCode() and getCurrentResponse()/getLastReceivedResponse(). Your next step at this point will be to call the PresenceSubscriber's processResponse() method to proceed with the SUBSCRIBE processing.
In the case of a fatal outcome, no subscription object 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 PresenceSubscriber 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 PresenceSubscriber 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 PresenceSubscriber 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 PresenceSubscriber 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 PresenceSubscriber object representing the user and puts the 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 PresenceSubscriber object yourself or retrieve it anytime later by calling this SipPhone's getBuddyInfo(buddy-uri). You will use the returned PresenceSubscriber 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 PresenceSubscriber methods getReturnCode() and getCurrentResponse()/getLastReceivedResponse(). Your next step at this point will be to call the PresenceSubscriber's processResponse() method to proceed with the SUBSCRIBE processing.
In the case of a fatal outcome, no Subscription object 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 PresenceSubscriber 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 PresenceSubscriber getBuddyInfo(java.lang.String uri)
uri - the URI (ie, sip:bob@nist.gov) of the user whose subscription
object is to be returned.
public java.util.Hashtable<java.lang.String,PresenceSubscriber> getBuddyList()
See related methods getBuddyInfo(), getRetiredBuddies().
public java.util.Hashtable<java.lang.String,PresenceSubscriber> getRetiredBuddies()
See related methods getBuddyInfo(), getBuddyList().
public java.util.List<ReferSubscriber> getRefererInfo(javax.sip.address.SipURI referToUri)
referToUri - the referToUri that was previously passed in to
SipPhone.refer(). See javadoc there.
public java.util.List<ReferSubscriber> getRefererInfoByDialog(java.lang.String dialogId)
dialogId - the dialog ID of interest
public java.util.List<ReferSubscriber> getRefererList()
See related method getRefererInfo().
public javax.sip.address.SipURI getUri(java.lang.String scheme,
java.lang.String userHostPort,
java.lang.String transportUriParameter,
java.lang.String methodUriParameter,
java.util.Map<java.lang.String,java.lang.String> otherUriParameters,
java.lang.String joinUriHeader,
java.lang.String replacesUriHeader,
java.lang.String bodyUriHeader,
java.util.Map<java.lang.String,java.lang.String> otherUriHeaders)
throws java.text.ParseException
scheme - "sip:" or "sips:" or null if the scheme is already included in
the userHostPort parameter.userHostPort - Addressing information in the form of: user@host:port. Port is
not required, and the scheme may optionally be included here
instead of in the "scheme" parameter. Examples:
sipmaster@192.168.1.11:5060 and sip:alice@atlanta.sip.com.transportUriParameter - Specifies which transport protocol to use for sending requests
and responses to this URI, or null if not needed.methodUriParameter - Specifies which SIP method to use in requests directed at this
URI (ie, INVITE), or null if not applicable.otherUriParameters - Remaining URI parameters affecting a request constructed from
this URI (Lr, MAddr, TTL, etc), or null if not applicable. URI
parameters are key-value pairs. Any given parameter name (key)
MUST NOT appear more than once.joinUriHeader - This value is the dialog ID for a Join header to be included
in a request constructed from this URI, or null if not
applicable.replacesUriHeader - This value is the dialog ID for a Replaces header to be
included in a request constructed from this URI, or null if
not applicable.bodyUriHeader - This value is the message body of a SIP request constructed
from this URI, or null if not applicable.otherUriHeaders - Remaining header fields to be included in a request
constructed from this URI, or null if not applicable. Header
fields are key-value pairs.
java.text.ParseException - On parse error due to invalid scheme or userHostPort
parameters.
public ReferSubscriber refer(java.lang.String refereeUri,
javax.sip.address.SipURI referToUri,
java.lang.String eventId,
long timeout,
java.lang.String viaNonProxyRoute)
This method blocks until one of the above outcomes is reached.
In the case of a positive response status code, this method returns a ReferSubscriber object that represents the implicit subscription. You can save the returned object yourself or retrieve it anytime later by calling one of this SipPhone's getReferrerInfo() methods or getRefererList(). Use the returned subscription object to proceed through the remainder of this REFER-NOTIFY sequence as well as for future SUBSCRIBE-NOTIFY sequences on this subscription and also to find out details at any given time such as the subscription state, amount of time left on the subscription, termination reason, 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 ReferSubscriber methods getReturnCode() and getCurrentResponse(). Your next step will then be to call the ReferSubscriber's processResponse() method to proceed with the REFER processing.
In the case of a fatal outcome, no subscription object 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).
refereeUri - The URI (ie, sip:bob@nist.gov) of the far end of the
subscription. This is the party the REFER request is sent to.referToUri - The URI that the refereeUri is to refer to. You can use
SipPhone.getUri() to create this object for you to pass in, or
you can create your own using the JAIN SIP API.eventId - The event "id" to use in the REFER message, or null for no
event "id" parameter. If an eventId is specified here, it will
be used subsequently for error checking the REFER responses
and the NOTIFYs from the far end as well as for sending
subsequent SUBSCRIBEs unless changed by the caller later when
invoking ReferSubscriber methods refresh() or unsubscribe().timeout - The maximum amount of time to wait for a response, in
milliseconds. Use a value of 0 to wait indefinitely.viaNonProxyRoute - Affects the routing of the REFER message. By default, the
message is routed to the Proxy that was specified when this
SipPhone object was created (SipStack.createSipPhone()) or if
no proxy was specified then, the REFER is looped back to this
local sip stack. If the viaNonProxyRoute parameter is not
null, it overrides the default behavior and causes the message
to be routed differently, to the viaNonProxyRoute node which
is specified as "hostaddress:port/transport" i.e.
129.1.22.333:5060/UDP. A route header will be added to the
REFER for this, before the request is sent.
public ReferSubscriber refer(java.lang.String refereeUri,
javax.sip.address.SipURI referToUri,
java.lang.String eventId,
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 ReferSubscriber refer(java.lang.String refereeUri,
javax.sip.address.SipURI referToUri,
java.lang.String eventId,
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, 'message' part of
'message/sipfrag'), 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, 'sipfrag' part of
'message/sipfrag'), 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 ReferSubscriber refer(javax.sip.Dialog dialog,
javax.sip.address.SipURI referToUri,
java.lang.String eventId,
long timeout)
This method blocks until one of the above outcomes is reached.
In the case of a positive response status code, this method returns a ReferSubscriber object that represents the implicit subscription. You can save the returned object yourself or retrieve it anytime later by calling one of this SipPhone's getReferrerInfo() methods or getRefererList(). Use the returned subscription object to proceed through the remainder of this REFER-NOTIFY sequence as well as for future SUBSCRIBE-NOTIFY sequences on this subscription and also to find out details at any given time such as the subscription state, amount of time left on the subscription, termination reason, 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 ReferSubscriber methods getReturnCode() and getCurrentResponse(). Your next step will then be to call the ReferSubscriber's processResponse() method to proceed with the REFER processing.
In the case of a fatal outcome, no subscription object 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).
dialog - The existing dialog that this REFER should be associated with.
You can get it from SipCall.getDialog() or
ReferSubscriber.getDialog().referToUri - The URI that the far end of the dialog is to refer to. You can
use SipPhone.getUri() to create this object for you to pass
in, or you can create your own using the JAIN SIP API.eventId - The event "id" to use in the REFER message, or null for no
event "id" parameter. If an eventId is specified here, it will
be used subsequently for error checking the REFER responses
and the NOTIFYs from the far end as well as for sending
subsequent SUBSCRIBEs unless changed by the caller later when
invoking ReferSubscriber methods refresh() or unsubscribe().timeout - The maximum amount of time to wait for a response, in
milliseconds. Use a value of 0 to wait indefinitely.
public ReferSubscriber refer(javax.sip.Dialog dialog,
javax.sip.address.SipURI referToUri,
java.lang.String eventId,
long timeout,
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 ReferSubscriber refer(javax.sip.Dialog dialog,
javax.sip.address.SipURI referToUri,
java.lang.String eventId,
long timeout,
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, 'message' part of
'message/sipfrag'), 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, 'sipfrag' part of
'message/sipfrag'), 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.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||