|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
SipConnection
is the base interface for SIP connections. SipConnection
holds the common properties and methods for subinterfaces SipClientConnection
and SipServerConnection
.
Connector.open()
.
An application SHOULD call close()
when it is finished with the connection.
It should be noticed that the Connector.open()
returns a
client mode connection (SipClientConnection
) or
server mode connection (SipConnectionNotifier
)
depending on the string (SIP URI) passed to the Connector.open()
.
The SIP URI is specified in RFC3261 [1] and here it takes general form of:
{scheme}:[{target}][{params}]
where:
scheme
is SIP scheme supported by the system sip
or
sips
target
is user network address in form of {user_name}@{target_host}[:{port}]
or {telephone_number}
, see examples below.
params
stands for additional SIP URI parameters like ;transport=udp
SipClientConnection
will be returned.
sip:[email protected] sip:[email protected]:5060 sips:[email protected]:5060;transport=tcp sip:+358-555-1234567;[email protected];user=phone
{scheme}:[{port}][{params}]
where:
scheme
is SIP scheme supported by the system sip
or
sips
port
optional port number e.g. 5060 or asterisk *. Asterisk * is used to detect shared
mode server connections (see below).
params
additional parameters e.g. like media feature tags. See below.
sip:*;type="application/<app_subtype>"[;<other_params>]
SipConnectionNotifier
in shared mode.
The SipConnectionNotifier
is sharing the user's SIP identity with other SIP
applications and also sharing the system listening port. Because the listening port is
shared the parameter 'type' identifying the application is mandatory in this
mode. Furthermore, the SIP registration is done by the system. The application does not
register itself separately.type
application identifier as MIME type feature tag, where <app_subtype>
is an unique application type/name. Example value: type="application/vnd.company.x-game"<other_params>
Other possible media feature tags or parameters (see RFC3840 [4])
SipConnectionNotifier
.
sip:[nnnn][;<params>]
SipConnectionNotifier
in
dedicated mode, where a dedicated listening port is opened for the application.
The SipConnectionNotifier
is listening to incoming SIP requests on
port number nnnn
. If the port number is omitted an arbitrary number is
allocated by the system. Application identifier 'type' and other media feature
parameters are optional. Since the user's SIP identity is not shared the application has
to do the SIP registration by itself.<params>
Optional media feature tag parameters e.g. 'type' and others (see RFC3840 [4]).
SipConnectionNotifier
.
// Shared mode, the application MIME type identifier is application/vnd.company.x-game SipConnectionNotifier scn = (SipConnectionNotifier) Connector.open("sip:*;type=\"application/vnd.company.x-game\""); // Dedicated mode, port number 5060 opened for the application SipConnectionNotifier scn = (SipConnectionNotifier) Connector.open("sip:5060"); // Dedicated mode, port number 5080, using secure transport // the application identifier is "application/messenger" SipConnectionNotifier scn = (SipConnectionNotifier) Connector.open("sips:5080;type=\"application/messenger\""); // Dedicated mode, dedicated port number selected by the system SipConnectionNotifier scn = (SipConnectionNotifier) Connector.open("sip:");
Connector.open()
specifies
the access mode. This is ignored in SIP API. This is because both connection modes:
client mode connection and server mode connection can
send and receive messages.
Connector
convenience methods to gain access to a
specific input or output stream directly are not supported by the SIP API. The
implementations MUST throw IOException
if these methods are
called with SIP URIs.
IllegalArgumentException
ConnectionNotFoundException
IOException
SecurityException
SipException
To allow the Java SIP API to share the system SIP identity or use application's own
identity, the following rules are defined when the SIP server connection is opened with
Connector.open():
Connector SIP URI | SIP Identity | Request routing | |
1) | sip:*;type= "application/subtype" |
- share system SIP port
- share system SIP identity - SIP register done by the system |
- route incoming SIP requests with MIME type feature tag "application/subtype" to this SipConnectionNotifier |
2) | sip:5080[;type= "application/subtype"] |
- use dedicated port number 5080
- use identity set by the application - application does the SIP register |
- route all incoming SIP requests on port 5080 to this SipConnectionNotifier. If the optional MIME type feature tag "application/subtype" is set, route only the requests with the matching tag. |
3) | sip: | - use dedicated port selected by the system
- use identity set by the application - application does the SIP register |
- route all incoming SIP requests to the selected port to this SipConnectionNotifier |
Accept-Contact | SDP media | Routing | |
1) | yes | - | Header field contains feature sets that describe UAs that the caller would like to reach. In this specification the minimum requirement is the application MIME type indicated by the Accept-Contact parameter 'type' |
2) | yes | yes | Same as case 1) |
3) | - | yes | (OPTIONAL) The request is routed based on SDP media information. |
The rule 1) defines the minimum required operation for this specification.
The SIP dispatcher should implement the decision rules defined in caller prefs
[RFC3841] specification. For security reasons the dispatcher implementation may
define routing rules that cannot be overridden by other applications.
If matching application is not found a suitable error response is sent e.g.
Accept-Contact: *;<feature_set>Where "*" is purely there to match the SIP extensions syntax and <feature_set> is a list of feature parameters.
Accept-Contact: *;type="application/vnd.company.battleships" Accept-Contact: *;type="application/x-chess"; Accept-Contact: *;audio;voice;mobility="mobile";Example of an incoming request with Accept-Contact header, matching the application MIME type "application/x-chess":
INVITE sip:[email protected] SIP/2.0 From: sip:[email protected] To: sip:[email protected] Accept-Contact: *;type="application/x-chess";explicit Content-Type: application/sdp ...SDP...
"microedition.sip.version"
. When
System.getProperty
is called with this key,
implementations conforming to this specification shall return the
version string "1.0.1"
.
SipClientConnection
,
SipServerConnection
,
SipConnectionNotifier
Method Summary | |
void |
addHeader(java.lang.String name,
java.lang.String value)
Adds a header to the SIP message. |
SipDialog |
getDialog()
Returns the current SIP dialog. |
java.lang.String |
getHeader(java.lang.String name)
Gets the header field value of specified header type. |
java.lang.String[] |
getHeaders(java.lang.String name)
Gets the header field value(s) of specified header type. |
java.lang.String |
getMethod()
Gets the SIP method. |
java.lang.String |
getReasonPhrase()
Gets SIP response reason phrase. |
java.lang.String |
getRequestURI()
Gets Request-URI. |
int |
getStatusCode()
Gets SIP response status code. |
java.io.InputStream |
openContentInputStream()
Returns InputStream to read SIP message body content. |
java.io.OutputStream |
openContentOutputStream()
Returns OutputStream to fill the SIP message body content. |
void |
removeHeader(java.lang.String name)
Removes header from the message. |
void |
send()
Sends the SIP message. |
void |
setHeader(java.lang.String name,
java.lang.String value)
Sets header value in SIP message. |
Methods inherited from interface javax.microedition.io.Connection |
close |
Method Detail |
public void send() throws java.io.IOException, SipException
java.io.IOException
- if the message could not be sent
or because of network failure.
SipException
- INVALID_STATE if the message
can not be sent in this state. INVALID_MESSAGE there was an error
in message format.public void setHeader(java.lang.String name, java.lang.String value) throws SipException, java.lang.IllegalArgumentException
name
- name of the header, either in full or compact form see [1] p.32value
- the header value
java.lang.IllegalArgumentException
- MAY be thrown if the header or value
is invalid.
SipException
- INVALID_STATE if header can not be set in this state. INVALID_OPERATION if the system does not allow to set this header.public void addHeader(java.lang.String name, java.lang.String value) throws SipException, java.lang.IllegalArgumentException
name
- name of the header, either in full or compact form see [1] p.32value
- the header value
java.lang.IllegalArgumentException
- MAY be thrown if the header or value
is invalid.
SipException
- INVALID_STATE if header can not be added in this state. INVALID_OPERATION if the system does not allow to add this header.public void removeHeader(java.lang.String name) throws SipException
name
- name of the header to be removed, either in full or compact form see [1] p.32
SipException
- INVALID_STATE if header can not be removed in this state. INVALID_OPERATION if the system does not allow to remove this header.public java.lang.String[] getHeaders(java.lang.String name)
name
- name of the header type, either in full or compact form see [1] p.32
public java.lang.String getHeader(java.lang.String name)
name
- name of the header type, either in full or compact form see [1] p.32
public java.lang.String getMethod()
public java.lang.String getRequestURI()
public int getStatusCode()
public java.lang.String getReasonPhrase()
public SipDialog getDialog()
SipDialog
).
SipDialog
public java.io.InputStream openContentInputStream() throws java.io.IOException, SipException
java.io.IOException
- if the InputStream can not be opened, because of an I/O error occurred.
SipException
- INVALID_STATE the InputStream can not be opened in this state (e.g. no message received).public java.io.OutputStream openContentOutputStream() throws java.io.IOException, SipException
java.io.IOException
- if the OutputStream can not be opened, because of an I/O error occurred.
SipException
- INVALID_STATE the OutputStream can not be opened in this state (e.g. no message initialized). UNKNOWN_LENGTH Content-Length header not set. UNKNOWN_TYPE Content-Type header not set.send()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |