Java Doc for SipClientConnectionImpl.java in  » 6.0-JDK-Modules » j2me » gov » nist » microedition » sip » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » j2me » gov.nist.microedition.sip 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   gov.nist.microedition.sip.SipClientConnectionImpl

SipClientConnectionImpl
public class SipClientConnectionImpl implements SipClientConnection(Code)
Client SIP connection implementation. This code is in the public domain.


Field Summary
final public static  intCOMPLETED
     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  intCREATED
    
final public static  intINITIALIZED
    
final public static  intPROCEEDING
     Proceeding, request has been sent, waiting for the response, or provisional 1xx response received.
final public static  intSTREAM_OPEN
     Stream Open, OutputStream opened with openContentOutputStream().
final public static  intTERMINATED
    
final public static  intUNAUTHORIZED
     Unauthorized, transaction completed with response 401 (Unauthorized) or 407 (Proxy Authentication Required).
protected  booleanenableInitCancel
     Permission of generating CANCEL request.
protected  intstate
    

Constructor Summary
protected  SipClientConnectionImpl(SipURI inputURI, SecurityToken classSecurityToken)
    
protected  SipClientConnectionImpl(URI requestURI, SipDialog sipDialog)
     Constructs the client connection implementation.

Method Summary
public  voidaddHeader(String name, String value)
     Adds a header to the SIP message.
protected  voidclearResponse()
     Clears the current response.
public  voidclose()
     Close the clientconnection.
public  intenableRefresh(SipRefreshListener srl)
     Enables the refresh on for the request to be sent.
protected  StringgetCallIdentifier()
    
protected  ClientTransactiongetClientTransaction()
     Gets the current client transaction.
public  SipDialoggetDialog()
     Returns the current SIP dialog.
public  StringgetHeader(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  StringgetMethod()
     Gets the SIP method.
public  StringgetReasonPhrase()
     Gets SIP response reason phrase.
public  RequestgetRequest()
     Gets the current request.
public  StringgetRequestURI()
     Gets Request-URI.
protected  ResponsegetResponse()
     Gets the response.
protected  SipConnectionNotifiergetSipConnectionNotifier()
     Gets the assigned SipConnectionNotifier.
protected  SipStackgetSipStack()
     Gets the current sip stack.
public  intgetState()
     Gets the current state of connection.
public  intgetStatusCode()
     Gets SIP response status code.
public  voidhandleMatchingNotify(Request notifyRequest)
     The stack connector notifies this class when it receive NOTIFY request matching the previous SUBSCRIBE or REFER request.
public  voidinitAck()
     Convenience method to initialize SipClientConnection with SIP request method ACK.
protected  voidinitBye()
     Initialize the session termination transaction.
public  SipClientConnectioninitCancel()
     Convenience method to initialize SipClientConnection with SIP request method CANCEL.
protected  voidinitNotify()
     Convenience method to initialize SipClientConnection with SIP request method NOTIFY.
public  voidinitRequest(String method, SipConnectionNotifier scn)
     Initializes the connection.
protected  voidnotifyResponseReceived(Response response, ClientTransaction inputClientTransaction)
     The stack connector notifies this class when it receive a new response.
public  InputStreamopenContentInputStream()
     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  OutputStreamopenContentOutputStream()
     Returns OutputStream to fill the SIP message body content. When calling close() on OutputStream the message will be sent to the network.
public  booleanreceive(long timeout)
     Receives SIP response message.
public  voidremoveHeader(String name)
     Reomves header from the SIP message.
public  voidsend()
     Sends the SIP message.
public  voidsetCredentials(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  voidsetHeader(String name, String value)
     Sets header value in SIP message.
public  voidsetListener(SipClientConnectionListener sccl)
     Sets the listener for incoming responses.
public  voidsetRequestURI(String newUri)
     Sets Request-URI explicitly.
protected  voidupdateAndSendRequestFromRefresh(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  OutputStreamupdateRequestAndOpenOutputStream(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.

Field Detail
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




Constructor Detail
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




Method Detail
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.



close
public void close() throws IOException(Code)
Close the clientconnection.
See Also:   javax.microedition.io.Connection.close



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



initRequest
public void initRequest(String method, SipConnectionNotifier scn) throws IllegalArgumentException, SipException(Code)
Initializes the connection.
Parameters:
  method - the operation to be performed
Parameters:
  scn - the state transition notifier
exception:
  IllegalArgumentException - if the parameters are notvalid
exception:
  SipException - if a transition error occurs
See Also:   SipClientConnection.initRequest



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.



Methods inherited from java.lang.Object
public boolean equals(Object obj)(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.