|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
SipDialog represents one SIP Dialog. The SipDialog can be retrieved from a SipConnection object, when it is available (at earliest after provisional 101-199 response).
Basically, two SIP requests can open a dialog:
SipClientConnection
in the same dialog can be obtained
by calling
getNewClientConnection(String method)
method. The dialog
is terminated when the transaction BYE-200 OK is completed.
For more information please refer to RFC 3261 [1], Chapter 12.
SipClientConnection
in the same dialog can be obtained
by calling
getNewClientConnection(String method)
method. The dialog
is terminated when a notifier sends a NOTIFY request
with a "Subscription-State" of "terminated" and there is no other
subscriptions alive with this dialog.
For more information please refer to RFC 3265 [2], Chapter 3.3.4.
SipDialog has following states (for both client and server side):
getNewClientConnection()
can not be called in this
state.
SipDialog
in conjunction with SipClientConnection
and SipServerConnection
. SipDialog
is used to send subsequent SUBSCRIBE request as well as detecting if received NOTIFY belongs to the same dialog (i.e. subscription). Further dialog information like "Call-ID" or "remote tag" can be read from the subsequent SipClientConnection
as demonstrated.
class SipDialogExample implements SipServerConnectionListener { SipDialog dialog; SipClientConnection scc; SipConnectionNotifier scn; String callID; String remoteTag; public void sendSubscribe() { try { scn = (SipConnectionNotifier) Connector.open("sip:"); scn.setListener(this); scc = (SipClientConnection) Connector.open("sip:[email protected]"); scc.initRequest("SUBSCRIBE", scn); scc.setHeader("From", "sip:[email protected]"); scc.setHeader("Accept", "application/pidf+xml"); scc.setHeader("Event", "presence"); scc.setHeader("Expires", "950"); String contact = new String("sip:user@"+scn.getLocalAddress()+":"+scn.getLocalPort()); scc.setHeader("Contact", contact); scc.send(); boolean resp = scc.receive(10000); // wait 10 secs for response if(resp) { if(scc.getStatusCode() == 200) { dialog = scc.getDialog(); // initialize new SipClientConnection scc = dialog.getNewClientConnection("SUBSCRIBE"); // read dialog Call-ID callID = scc.getHeader("Call-ID"); // read remote tag SipHeader sh = new SipHeader("To", scc.getHeader("To")); remoteTag = sh.getParameter("tag"); // unSUBSCRIBE scc.setHeader("Expires", "0"); scc.send(); } } else { // didn't receive any response in given time } } catch(Exception ex) { // handle Exceptions } } public void notifyRequest(SipConnectionNotifier scn) { try { SipServerConnection ssc; // retrieve the request received ssc = scn.acceptAndOpen(); // check if the received request is NOTIFY and it belongs to our dialog if(ssc.getMethod().equals("NOTIFY") && dialog.isSameDialog(ssc)) { ssc.initResponse(200); ssc.send(); }else { // send 481 "Subscription does not exist" ssc.initResponse(481); ssc.send(); } } catch(Exception ex) { // handle Exceptions } } }
SipConnection.getDialog()
Field Summary | |
static byte |
CONFIRMED
|
static byte |
EARLY
|
static byte |
TERMINATED
|
Method Summary | |
java.lang.String |
getDialogID()
Returns the ID of the SIP Dialog. |
SipClientConnection |
getNewClientConnection(java.lang.String method)
Returns a new SipClientConnection in this dialog. |
byte |
getState()
Returns the state of the SIP Dialog. |
boolean |
isSameDialog(SipConnection sc)
Does the given SipConnection belong to this dialog. |
Field Detail |
public static final byte EARLY
public static final byte CONFIRMED
public static final byte TERMINATED
Method Detail |
public SipClientConnection getNewClientConnection(java.lang.String method) throws java.lang.IllegalArgumentException, SipException
To From CSeq Call-ID Max-Forwards Via Contact Route // if the dialog route is not empty
java.lang.IllegalArgumentException
- if the method is invalid
SipException
- INVALID_STATE if the
new connection can not be established in the current state of dialog.public boolean isSameDialog(SipConnection sc)
sc
- SipConnection to be checked, can be either SipClientConnection or SipServerConnection
public byte getState()
public java.lang.String getDialogID()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |