📄 sipserverconnection.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--NewPage-->
<HTML>
<HEAD>
<!-- Generated by javadoc (build 1.4.2_10) on Wed Feb 28 12:31:09 CET 2007 -->
<TITLE>
SipServerConnection (JSR180 SIP API for J2ME)
</TITLE>
<META NAME="keywords" CONTENT="javax.microedition.sip.SipServerConnection interface">
<LINK REL ="stylesheet" TYPE="text/css" HREF="../../../stylesheet.css" TITLE="Style">
<SCRIPT type="text/javascript">
function windowTitle()
{
parent.document.title="SipServerConnection (JSR180 SIP API for J2ME)";
}
</SCRIPT>
</HEAD>
<BODY BGCOLOR="white" onload="windowTitle();">
<!-- ========= START OF TOP NAVBAR ======= -->
<A NAME="navbar_top"><!-- --></A><A HREF="#skip-navbar_top" title="Skip navigation links"></A><TABLE BORDER="0" WIDTH="100%" CELLPADDING="1" CELLSPACING="0" SUMMARY="">
<TR>
<TD COLSPAN=3 BGCOLOR="#EEEEFF" CLASS="NavBarCell1">
<A NAME="navbar_top_firstrow"><!-- --></A><TABLE BORDER="0" CELLPADDING="0" CELLSPACING="3" SUMMARY="">
<TR ALIGN="center" VALIGN="top">
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../overview-summary.html"><FONT CLASS="NavBarFont1"><B>Overview</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-summary.html"><FONT CLASS="NavBarFont1"><B>Package</B></FONT></A> </TD>
<TD BGCOLOR="#FFFFFF" CLASS="NavBarCell1Rev"> <FONT CLASS="NavBarFont1Rev"><B>Class</B></FONT> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="package-tree.html"><FONT CLASS="NavBarFont1"><B>Tree</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../deprecated-list.html"><FONT CLASS="NavBarFont1"><B>Deprecated</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../index-all.html"><FONT CLASS="NavBarFont1"><B>Index</B></FONT></A> </TD>
<TD BGCOLOR="#EEEEFF" CLASS="NavBarCell1"> <A HREF="../../../help-doc.html"><FONT CLASS="NavBarFont1"><B>Help</B></FONT></A> </TD>
</TR>
</TABLE>
</TD>
<TD ALIGN="right" VALIGN="top" ROWSPAN=3><EM>
</EM>
</TD>
</TR>
<TR>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../javax/microedition/sip/SipRefreshListener.html" title="interface in javax.microedition.sip"><B>PREV CLASS</B></A>
<A HREF="../../../javax/microedition/sip/SipServerConnectionListener.html" title="interface in javax.microedition.sip"><B>NEXT CLASS</B></A></FONT></TD>
<TD BGCOLOR="white" CLASS="NavBarCell2"><FONT SIZE="-2">
<A HREF="../../../index.html" target="_top"><B>FRAMES</B></A>
<A HREF="SipServerConnection.html" target="_top"><B>NO FRAMES</B></A>
<SCRIPT type="text/javascript">
<!--
if(window==top) {
document.writeln('<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>');
}
//-->
</SCRIPT>
<NOSCRIPT>
<A HREF="../../../allclasses-noframe.html"><B>All Classes</B></A>
</NOSCRIPT>
</FONT></TD>
</TR>
<TR>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
SUMMARY: NESTED | FIELD | CONSTR | <A HREF="#method_summary">METHOD</A></FONT></TD>
<TD VALIGN="top" CLASS="NavBarCell3"><FONT SIZE="-2">
DETAIL: FIELD | CONSTR | <A HREF="#method_detail">METHOD</A></FONT></TD>
</TR>
</TABLE>
<A NAME="skip-navbar_top"></A><!-- ========= END OF TOP NAVBAR ========= -->
<HR>
<!-- ======== START OF CLASS DATA ======== -->
<H2>
<FONT SIZE="-1">
javax.microedition.sip</FONT>
<BR>
Interface SipServerConnection</H2>
<DL>
<DT><B>All Superinterfaces:</B> <DD>javax.microedition.io.Connection, <A HREF="../../../javax/microedition/sip/SipConnection.html" title="interface in javax.microedition.sip">SipConnection</A></DD>
</DL>
<HR>
<DL>
<DT>public interface <B>SipServerConnection</B><DT>extends <A HREF="../../../javax/microedition/sip/SipConnection.html" title="interface in javax.microedition.sip">SipConnection</A></DL>
<P>
<tt>SipServerConnection</tt> represents a SIP server transaction. <tt>SipServerConnection</tt> is created by the <tt>SipConnectionNotifier</tt> when a new request is received. <br> <br> The <tt>SipServerConnection</tt> has following state diagram:<br> <IMG SRC="./jsr180-server-state-diagram.gif"> <UL> <LI> <em>Created</em>, <tt>SipServerConnection</tt> created. <LI> <em>Request Received</em>, <tt>SipServerConnection</tt> returned from <tt>SipConnectionNotifier</tt> (not ACK). <br>or provisional response(s) (1xx) sent. <LI> <em>Initialized</em>, response initialized calling <tt>initResponse()</tt> <LI> <em>Stream Open</em>, <tt>OutputStream</tt> opened with <tt>openContentOutputStream()</tt>. Opening <tt>InputStream</tt> for received request does not trigger state transition. <LI> <em>Completed</em>, transaction completed with sending final response (2xx, 3xx, 4xx, 5xx, 6xx) <br>or resent 2xx <br>or <tt>SipServerConnection</tt> for ACK returned from <tt>SipConnectionNotifier</tt> <LI> <em>Terminated</em>, the final state, in which the SIP connection has been terminated by error or closed </UL> <FONT SIZE="2"><b>Note:</b> The state diagram of <tt>SipServerConnection</tt> differs from the state diagram of SIP server transaction, which can be found in RFC 3261 [1] p.136-140</FONT> <br><br> Following methods are restricted to certain states. The table below shows the list of methods available per state. <UL> <LI> <em>Request Received</em><br><code> initResponse<br> openContentInputStream<br></code> <LI> <em>Initialized</em><br><code> addHeader<br> setHeader<br> removeHeader<br> setReasonPhrase<br> openContentOutputStream<br> send<br></code> <LI> <em>Stream Open</em><br> Methods in <code>OutputStream</code> and <code>SipConnection.send</code> <LI> <em>Completed</em><br><code> send</code> // only for resending 2xx responses<br> All get-methods, see below <LI> <em>Terminated</em><br> The transaction and this connection is closed. The methods above throw <tt>SipException.INVALID_STATE</tt> if that is specified to the method and <tt>IOException</tt> for those methods (e.g. methods of Input/OutputStream) that does not have <tt>SipException</tt> specified. Methods that don't throw checked exceptions return without any action or return <tt>null</tt> as appropriate. </UL> Following methods can be called in every state. The functionality is defined by the method depending on the information availability. <UL> <LI> <em>Can be called in every state (with the exception of setErrorListener).</em> Accessors return <tt>null</tt> in the <em>Terminated</em> state.<br><code> getHeader<br> getHeaders<br> getRequestURI<br> getMethod<br> getStatusCode<br> getReasonPhrase<br> getDialog<br> setErrorListener // can not be called in <em>Terminated</em> state<br> close </code> // causes state transition to <em>Terminated</em> state </UL><H4>Error response for INVITE</H4> If an error response is sent to the INVITE request, the client transaction layer will generate the ACK automatically on behalf of the transaction user (TU). Now when this ACK arrives on the server it is not passed up to TU as a new <tt>SipServerConnection</tt>. See RFC 3261 [1] p.136 <code>"Figure 7: INVITE server transaction".</code><H4>Resending 2xx for INVITE</H4> If the ACK is not received for the final 2xx response, it is up to the TU (UA core) to resend 2xx response. In order to resend the 2xx response the <tt>SipServerConnection.send()</tt> can be called also in <em>Completed</em> state. See RFC 3261 [1] p.124 <code>"17 Transactions"</code> and p.135 <code>"17.2.1 INVITE Server Transaction"</code>.<H3>Code Examples</H3> Following code example illustrates the usage of SIP server connection: opening, receiving one request (MESSAGE) and sending response: <p><p><pre> public receiveMessage() { SipConnectionNotifier scn = null; SipServerConnection ssc = null; String method = null; try { // Open SIP server connection and listen to port 5060 scn = (SipConnectionNotifier) Connector.open("sip:5060"); // block and wait for incoming request. // SipServerConnection is establised and returned // when new request is received. ssc = scn.acceptAndOpen(); // what was the SIP method method = ssc.getMethod(); if(method.equals("MESSAGE")) { // read the content of the MESSAGE String contentType = ssc.getHeader("Content-Type"); if((contentType != null) && contentType.equals("text/plain")) { InputStream is = ssc.openContentInputStream(); int ch; // read content while ((ch = is.read()) != -1) { ... } } // initialize SIP 200 OK and send it back ssc.initResponse(200); ssc.send(); ssc.close(); } } catch(Exception ex) { // handle IOException, InterruptedIOException, SecurityException // or SipException } } </pre>
<P>
<P>
<DL>
<DT><B>See Also:</B><DD><A HREF="../../../javax/microedition/sip/SipConnectionNotifier.html" title="interface in javax.microedition.sip"><CODE>SipConnectionNotifier</CODE></A>, <A HREF="../../../javax/microedition/sip/SipServerConnectionListener.html" title="interface in javax.microedition.sip"><CODE>SipServerConnectionListener</CODE></A>, <A HREF="../../../javax/microedition/sip/SipClientConnection.html" title="interface in javax.microedition.sip"><CODE>SipClientConnection</CODE></A></DL>
<HR>
<P>
<!-- ======== NESTED CLASS SUMMARY ======== -->
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -