| java.lang.Object gov.nist.microedition.sip.SipClientConnectionImpl
Field Summary | |
final public static int | COMPLETED Completed, transaction completed with final response
(2xx, 3xx, 4xx, 5xx, 6xx) in this state the ACK can be initialized.
Multiple 200 OK responses can be received. | final public static int | CREATED | final public static int | INITIALIZED | final public static int | PROCEEDING Proceeding, request has been sent, waiting for the response, or
provisional 1xx response received. | final public static int | STREAM_OPEN Stream Open, OutputStream opened with openContentOutputStream(). | final public static int | TERMINATED | final public static int | UNAUTHORIZED Unauthorized, transaction completed with response 401
(Unauthorized) or 407 (Proxy Authentication Required). | protected boolean | enableInitCancel Permission of generating CANCEL request. | protected int | state |
Method Summary | |
public void | addHeader(String name, String value) Adds a header to the SIP message. | protected void | clearResponse() Clears the current response. | public void | close() Close the clientconnection. | public int | enableRefresh(SipRefreshListener srl) Enables the refresh on for the request to be sent. | protected String | getCallIdentifier() | protected ClientTransaction | getClientTransaction() Gets the current client transaction. | public SipDialog | getDialog() Returns the current SIP dialog. | public String | getHeader(String name) Gets the header field value of specified header type.
Parameters: name - - name of the header type, either in full or compact form.RFC 3261 p.32 topmost header field value, or null if thecurrent message does not have such a header or the header is for otherreason not available (e.g. | public String[] | getHeaders(String name) Gets the header field value(s) of specified header type
Parameters: name - - name of the header, either in full or compact form.RFC 3261 p.32 array of header field values (topmost first), or null if thecurrent message does not have such a header or the header is for otherreason not available (e.g. | public String | getMethod() Gets the SIP method. | public String | getReasonPhrase() Gets SIP response reason phrase. | public Request | getRequest() Gets the current request. | public String | getRequestURI() Gets Request-URI. | protected Response | getResponse() Gets the response. | protected SipConnectionNotifier | getSipConnectionNotifier() Gets the assigned SipConnectionNotifier. | protected SipStack | getSipStack() Gets the current sip stack. | public int | getState() Gets the current state of connection. | public int | getStatusCode() Gets SIP response status code. | public void | handleMatchingNotify(Request notifyRequest) The stack connector notifies this class when it receive NOTIFY
request matching the previous SUBSCRIBE or REFER request. | public void | initAck() Convenience method to initialize SipClientConnection with SIP request
method ACK. | protected void | initBye() Initialize the session termination transaction. | public SipClientConnection | initCancel() Convenience method to initialize SipClientConnection with SIP request
method CANCEL. | protected void | initNotify() Convenience method to initialize SipClientConnection with SIP request
method NOTIFY. | public void | initRequest(String method, SipConnectionNotifier scn) Initializes the connection. | protected void | notifyResponseReceived(Response response, ClientTransaction inputClientTransaction) The stack connector notifies this class when it receive a new response. | public InputStream | openContentInputStream() Returns InputStream to read SIP message body content.
InputStream to read body content throws: java.io.IOException - - if the InputStream can not be opened,because of an I/O error occurred. throws: SipException - - INVALID_STATE the InputStream can not be openedin this state (e.g. | public OutputStream | openContentOutputStream() Returns OutputStream to fill the SIP message body content.
When calling close() on OutputStream the message will be sent
to the network. | public boolean | receive(long timeout) Receives SIP response message. | public void | removeHeader(String name) Reomves header from the SIP message. | public void | send() Sends the SIP message. | public void | setCredentials(String username, String password, String realm) Sets credentials for possible digest authentication.
The application can set multiple credential triplets
(username, password, realm) for one SipClientConnection.
The username and password are specified for certain protection domain,
which is defined by the realm parameter.
The credentials can be set:
before sending the original request in Initialized state.
The API implementation caches the credentials for later use.
when 401 (Unauthorized) or 407 (Proxy Authentication Required) response
is received in the Unauthorized state. | public void | setHeader(String name, String value) Sets header value in SIP message. | public void | setListener(SipClientConnectionListener sccl) Sets the listener for incoming responses. | public void | setRequestURI(String newUri) Sets Request-URI explicitly. | protected void | updateAndSendRequestFromRefresh(Request updatedRequest) Updates and sends the request from the refresh.
Parameters: updatedRequest - the updated request throws: IOException - if the message could not be sent or becauseof network failure throws: InterruptedIOException - if a timeout occurs whileeither tryingto send the message or if this Connection object is closedduring this send operation throws: SipException - INVALID_STATE if the message cannot be sentin this state. | protected OutputStream | updateRequestAndOpenOutputStream(Request updatedRequest) Updates the request and calls openContentOutputStream()
to fill the new message body.
Parameters: updatedRequest - the updated request OutputStream to write body content throws: IOException - if the OutputStream can not be opened,because of an I/O error occurred. throws: SipException - INVALID_STATE the OutputStream can not be openedin this state (e.g. |
COMPLETED | final public static int COMPLETED(Code) | | Completed, transaction completed with final response
(2xx, 3xx, 4xx, 5xx, 6xx) in this state the ACK can be initialized.
Multiple 200 OK responses can be received. Note different state
transition for responses 401 and 407.
|
CREATED | final public static int CREATED(Code) | | Created, SipClientConnection created from Connector or SipDialog
|
INITIALIZED | final public static int INITIALIZED(Code) | | Initialized, request has been initialized with initRequest(...)
or initAck() or initCancel()
|
PROCEEDING | final public static int PROCEEDING(Code) | | Proceeding, request has been sent, waiting for the response, or
provisional 1xx response received. initCancel() can be called,
which will spawn a new SipClientConnection which is in
Initialized state
|
STREAM_OPEN | final public static int STREAM_OPEN(Code) | | Stream Open, OutputStream opened with openContentOutputStream().
Opening InputStream for received response does not trigger
state transition.
|
TERMINATED | final public static int TERMINATED(Code) | | Terminated, the final state, in which the SIP connection has
been terminated by error or closed
|
UNAUTHORIZED | final public static int UNAUTHORIZED(Code) | | Unauthorized, transaction completed with response 401
(Unauthorized) or 407 (Proxy Authentication Required). The
application can re-originate the request with proper
credentials by calling setCredentials() method. After this the
SipClientConnection is back in Proceeding state.
|
enableInitCancel | protected boolean enableInitCancel(Code) | | Permission of generating CANCEL request.
|
state | protected int state(Code) | | current state of this client transaction
|
SipClientConnectionImpl | protected SipClientConnectionImpl(SipURI inputURI, SecurityToken classSecurityToken) throws IllegalArgumentException(Code) | | Creates a sip Client Connection to send a request to the
following SIP URI user@host:portNumber;parameters
Parameters: inputURI - input SIP URI Parameters: classSecurityToken - Security token for SIP/SIPS protocol class |
SipClientConnectionImpl | protected SipClientConnectionImpl(URI requestURI, SipDialog sipDialog) throws IllegalArgumentException(Code) | | Constructs the client connection implementation.
Parameters: requestURI - the target SIP session URI Parameters: sipDialog - the current transaction state |
addHeader | public void addHeader(String name, String value) throws SipException, IllegalArgumentException(Code) | | Adds a header to the SIP message. If multiple header field values exist
the header value is added topmost of this type of headers.
The implementations MAY restrict the access to some headers
according to RFC 3261.
Parameters: name - - name of the header, either in full or compact form.RFC 3261 p.32 Parameters: value - - the header value throws: SipException - - INVALID_STATE if header can not be added inthis state. INVALID_OPERATION if the system does not allow to addthis header. throws: IllegalArgumentException - - MAY be thrown if the header orvalue is invalid |
clearResponse | protected void clearResponse()(Code) | | Clears the current response.
|
enableRefresh | public int enableRefresh(SipRefreshListener srl) throws SipException(Code) | | Enables the refresh on for the request to be sent. The method return a
refresh ID, which can be used to update or stop the refresh.
Parameters: srl - - callback interface for refresh events, if this is null themethod returns 0 and refresh is not enabled. refresh ID. If the request is not refreshable returns 0. throws: SipException - - INVALID_STATE if the refresh can not be enabledin this state. |
getCallIdentifier | protected String getCallIdentifier()(Code) | | Return the Call Identifier of this client connection
If there is no call id yet, this method return an empty String
the call Identifier |
getClientTransaction | protected ClientTransaction getClientTransaction()(Code) | | Gets the current client transaction.
the current client transaction |
getDialog | public SipDialog getDialog()(Code) | | Returns the current SIP dialog. This is available when the SipConnection
belongs to a created SipDialog and the system has received (or sent)
provisional (101-199) or final response (200).
SipDialog object if this connection belongs to a dialog,otherwise returns null. |
getHeader | public String getHeader(String name)(Code) | | Gets the header field value of specified header type.
Parameters: name - - name of the header type, either in full or compact form.RFC 3261 p.32 topmost header field value, or null if thecurrent message does not have such a header or the header is for otherreason not available (e.g. message not initialized).Javadoc is not clear on whether this method should be applied torequest or response. The NIST implementation uses response; but thatseems to be wrong. |
getHeaders | public String[] getHeaders(String name)(Code) | | Gets the header field value(s) of specified header type
Parameters: name - - name of the header, either in full or compact form.RFC 3261 p.32 array of header field values (topmost first), or null if thecurrent message does not have such a header or the header is for otherreason not available (e.g. message not initialized).Javadoc is not clear on whether this method should be applied torequest or response. The NIST implementation uses response only tocalculate the size; but that seems to be wrong. |
getMethod | public String getMethod()(Code) | | Gets the SIP method. Applicable when a message has been
initialized or received.
SIP method name REGISTER, INVITE, NOTIFY, etc. Returns null ifthe method is not available. |
getReasonPhrase | public String getReasonPhrase()(Code) | | Gets SIP response reason phrase. Available when SipClientConnection is in
Proceeding or Completed state or when SipServerConnection is in
Initialized state.
reason phrase. Returns null if the reason phrase isnot available. |
getRequest | public Request getRequest()(Code) | | Gets the current request.
the current request |
getRequestURI | public String getRequestURI()(Code) | | Gets Request-URI. Available when SipClientConnection is in Initialized
state or when SipServerConnection is in Request Received state.
Built from the original URI given in Connector.open().
See RFC 3261 p.35 (8.1.1.1 Request-URI)
Request-URI of the message. Returns null if the Request-URIis not available. |
getResponse | protected Response getResponse()(Code) | | Gets the response.
the response instance |
getSipConnectionNotifier | protected SipConnectionNotifier getSipConnectionNotifier()(Code) | | Gets the assigned SipConnectionNotifier.
the current SipConnectionNotifier |
getSipStack | protected SipStack getSipStack()(Code) | | Gets the current sip stack.
the current sip stack |
getState | public int getState()(Code) | | Gets the current state of connection.
the current state |
getStatusCode | public int getStatusCode()(Code) | | Gets SIP response status code. Available when SipClientConnection is in
Proceeding or Completed state or when SipServerConnection is in
Initialized state.
status code 1xx, 2xx, 3xx, 4xx, ... Returns 0 if the status codeis not available. |
handleMatchingNotify | public void handleMatchingNotify(Request notifyRequest)(Code) | | The stack connector notifies this class when it receive NOTIFY
request matching the previous SUBSCRIBE or REFER request.
Parameters: notifyRequest - NOTIFY request to process |
initAck | public void initAck() throws SipException(Code) | | Convenience method to initialize SipClientConnection with SIP request
method ACK. ACK can be applied only to INVITE request.
See Also: JSR180 See Also: spec, v 1.0.1, p 27 |
initBye | protected void initBye()(Code) | | Initialize the session termination transaction.
|
initCancel | public SipClientConnection initCancel() throws SipException(Code) | | Convenience method to initialize SipClientConnection with SIP request
method CANCEL.
A new SipClientConnection with preinitialized CANCEL request. throws: SipException - - INVALID_STATE if the request can not be set,because of wrong state (in SipClientConnection) or the systemhas alreadygot the 200 OK response (even if not read with receive() method).INVALID_OPERATION if CANCEL method can not be applied to the currentrequest method. See Also: javax.microedition.sip.SipClientConnection.initCancel |
initNotify | protected void initNotify()(Code) | | Convenience method to initialize SipClientConnection with SIP request
method NOTIFY.
This method is copied from latest updates to NIST workspace
|
notifyResponseReceived | protected void notifyResponseReceived(Response response, ClientTransaction inputClientTransaction)(Code) | | The stack connector notifies this class when it receive a new response.
Parameters: response - the repsonse event to be propagated Parameters: inputClientTransaction - client transaction of this response |
openContentInputStream | public InputStream openContentInputStream() throws IOException, SipException(Code) | | Returns InputStream to read SIP message body content.
InputStream to read body content throws: java.io.IOException - - if the InputStream can not be opened,because of an I/O error occurred. throws: SipException - - INVALID_STATE the InputStream can not be openedin this state (e.g. no message received). |
openContentOutputStream | public OutputStream openContentOutputStream() throws IOException, SipException(Code) | | Returns OutputStream to fill the SIP message body content.
When calling close() on OutputStream the message will be sent
to the network. So it is equivalent to call send(). Again send() must
not be called after closing the OutputStream, since it will throw
Exception because of calling the method in wrong state.
Before opening OutputStream the Content-Length and Content-Type headers
has to se set. If not SipException.UNKNOWN_LENGTH or
SipException.UNKNOWN_TYPE will be thrown respectively.
OutputStream to write body content throws: IOException - if the OutputStream can not be opened,because of an I/O error occurred. throws: SipException - INVALID_STATE the OutputStream can not be openedin this state (e.g. no message initialized).UNKNOWN_LENGTH Content-Length header not set.UNKNOWN_TYPE Content-Type header not set. |
receive | public boolean receive(long timeout) throws SipException, IOException(Code) | | Receives SIP response message. The receive method will update the
SipClientConnection with the last new received response.
If no message is received the method will block until something is
received or specified amount of time has elapsed.
Parameters: timeout - - the maximum time to wait in milliseconds.0 = do not wait, just poll Returns true if response was received. Returns false ifthe given timeout elapsed and no response was received. throws: SipException - - INVALID_STATE if the receive can not becalled because of wrong state. throws: IOException - - if the message could not be received orbecause of network failure |
removeHeader | public void removeHeader(String name) throws SipException, IllegalArgumentException(Code) | | Reomves header from the SIP message. If multiple header field
values exist
the topmost is removed.
The implementations MAY restrict the access to some headers
according to RFC 3261.
If the named header is not found this method does nothing.
Parameters: name - - name of the header to be removed, either intfull or compact form RFC 3261 p.32. throws: SipException - - INVALID_STATE if header can not be removed inthis state. INVALID_OPERATION if the system does not allow to removethis header. |
send | public void send() throws IOException, InterruptedIOException, SipException(Code) | | Sends the SIP message. Send must also close the OutputStream
if it was opened.
throws: IOException - if the message could not be sent or becauseof network failure throws: InterruptedIOException - if a timeout occurs whileeither tryingto send the message or if this Connection object is closedduring this send operation throws: SipException - INVALID_STATE if the message cannot be sentin this state. INVALID_MESSAGE there was an errorin message format |
setCredentials | public void setCredentials(String username, String password, String realm) throws SipException(Code) | | Sets credentials for possible digest authentication.
The application can set multiple credential triplets
(username, password, realm) for one SipClientConnection.
The username and password are specified for certain protection domain,
which is defined by the realm parameter.
The credentials can be set:
before sending the original request in Initialized state.
The API implementation caches the credentials for later use.
when 401 (Unauthorized) or 407 (Proxy Authentication Required) response
is received in the Unauthorized state. The API implementation uses the
given credentials to re-originate the request with proper authorization
header. After that the SipClientConnection will be in Proceeding state.
Parameters: username - username (for this protection domain) Parameters: password - user password (for this protection domain) Parameters: realm - defines the protection domain throws: SipException - INVALID_STATE if the credentials can notbe set in this state. throws: NullPointerException - - if the username, password or realm is null |
setHeader | public void setHeader(String name, String value) throws SipException, IllegalArgumentException(Code) | | Sets header value in SIP message. If the header does not exist
it will be added to the message, otherwise the existing header is
overwritten. If multiple header field values exist the topmost is
overwritten. The implementations MAY restrict the access to some headers
according to RFC 3261.
Parameters: name - - name of the header, either in full or compact form.RFC 3261 p.32 Parameters: value - - the header value throws: SipException - - INVALID_STATE if header can not be set inthis state. INVALID_OPERATION if the system does not allow to setthis header. throws: IllegalArgumentException - - MAY be thrown if the header orvalue is invalid |
setListener | public void setListener(SipClientConnectionListener sccl) throws IOException(Code) | | Sets the listener for incoming responses. If a listener is
already set it
will be overwritten. Setting listener to null will remove the current
listener.
Parameters: sccl - - reference to the listener object. Value null will removethe existing listener. throws: IOException - - if the connection is closed. |
setRequestURI | public void setRequestURI(String newUri) throws IllegalArgumentException, SipException(Code) | | Sets Request-URI explicitly. Request-URI can be set only in
Initialized state.
Parameters: newUri - Request-URI throws: IllegalArgumentException - MAY be thrown if the URI is invalid throws: SipException - INVALID_STATE if the Request-URI can not be set,because of wrong state.INVALID_OPERATION if the Request-URI is not allowed to be set. |
updateAndSendRequestFromRefresh | protected void updateAndSendRequestFromRefresh(Request updatedRequest) throws IOException, InterruptedIOException, SipException(Code) | | Updates and sends the request from the refresh.
Parameters: updatedRequest - the updated request throws: IOException - if the message could not be sent or becauseof network failure throws: InterruptedIOException - if a timeout occurs whileeither tryingto send the message or if this Connection object is closedduring this send operation throws: SipException - INVALID_STATE if the message cannot be sentin this state. INVALID_MESSAGE there was an errorin message format |
updateRequestAndOpenOutputStream | protected OutputStream updateRequestAndOpenOutputStream(Request updatedRequest) throws IOException, SipException(Code) | | Updates the request and calls openContentOutputStream()
to fill the new message body.
Parameters: updatedRequest - the updated request OutputStream to write body content throws: IOException - if the OutputStream can not be opened,because of an I/O error occurred. throws: SipException - INVALID_STATE the OutputStream can not be openedin this state (e.g. no message initialized).UNKNOWN_LENGTH Content-Length header not set.UNKNOWN_TYPE Content-Type header not set. |
|
|