|
JSIP API v1.2 November 2006 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Dialog
A dialog represents a peer-to-peer SIP relationship between two user agents that persists for some time. Dialogs are typically used by user agents to facilitate management of state. Dialogs are typically not relevant to proxy servers. The dialog facilitates sequencing of messages between the user agents and proper routing of requests between both of them. The dialog represents a context in which to interpret SIP Transactions and Messages. However, a Dialog is not necessary for message processing.
A dialog is identified at each User Agent with a dialog Id, which consists of a Call-Id value, a local tag and a remote tag. The dialog Id at each User Agent involved in the dialog is not the same. Specifically, the local tag at one User Agent is identical to the remote tag at the peer User Agent. The tags are opaque tokens that facilitate the generation of unique dialog Ids.
A dialog contains certain pieces of data needed for further message transmissions within the dialog. This data consists of:
DialogState
is
determined by the sequence of messages that occur on the initial dialog.
Invite Dialog States:
Null --> Early --> Confirmed --> Terminated
Other Dialog-creating Requests
Dialog States (ie. SUBSCRIBE):
Null --> Confirmed --> Terminated.
The Listener MUST ACK the 2xx response associated with an INVITE dialog. Retransmissions of the ACK in response to subsequent INVITE requests are handled by the dialog layer. If a listener does not ACK a 2XX response immediately, the implementation will terminate the Dialog automatically and remove it from the stack when the listener completes its execution.
The dialog layer MUST respond with an automatic error response when RFC3261 specifies that the User Agent MUST respond with a certain error. This does not apply for successful responses like 200 OK. The error condition relates directly to the dialog layer and the SipListener can add no meaningful information to the response. Such a response can be constructed and sent entirely by the dialog layer on behalf of the SipListener. Under such circumstances, it makes sense to let the dialog support handle the response and not bother the SipListener with it. The SipListener will not be notified with the RequestEvent upon which the Response was sent on its behalf by the Dialog layer. However, if no Dialog is registered for the transaction either automatically or under application control, then the SipListener is expected to generate and send the appropriate (error) response.
For example: In RFC3261 Chapter 14 a User Agent
Server that receives a second INVITE before it sends the final response to a
first INVITE with a lower CSeq sequence number on the same dialog MUST return
a 500 (Server Internal Error) response to the second INVITE and MUST include
a Retry-After header field with a randomly chosen value of between 0 and 10
seconds.
In this release of this specification, the implementation handles retransmissions of
Responses that are specified as being handled by the UA core, if there is an
associated Dialog for a given transaction.
If there is no associated Dialog for a given transaction, the application
will be alerted to perform the retransmissions required by the UA core if
desired. Applications should explicitly request such alerts see
ServerTransaction.enableRetransmissionAlerts()
. Once enabled the
SipProvider will deliver retransmission timer
events to the Listener with a Timeout.RETRANSMIT
notification. The
SipListener can then retransmit the Response as necessary, see
SipListener.processTimeout(TimeoutEvent)
.
For INVITE Client Transactions:
ServerTransaction.sendResponse(Response)
.
ServerTransaction.enableRetransmissionAlerts()
the SipListener is
periodically alerted to retransmit 2xx responses for the ServerTransaction.sendReliableProvisionalResponse(Response)
Multiple 2xx responses may arrive at the UAC for a single INVITE request due to a forking proxy. Each response is distinguished by the tag parameter in the TO header field, and each represents a distinct Dialog, with a distinct Dialog identifier. In this case the first 2xx terminates the original INVITE additional 2xx responses will be presented to the SipListener as a ResponseEvent with null Client Transaction ID but with a valid and distinct Dialog. The Listener is expected to ACK the 2xx response - otherwise the Dialog is terminated after a timeout period. Note that unless automatic dialog creation is explictly disabled, the 2xx ResponseEvent will always contain a Dialog whether or not the outgoing INVITE was sent through a ClientTransaction or statelessly via a SipProvider.
Method Summary | |
---|---|
Request |
createAck(long cseq)
Creates an ACK request for an Invite that was responded with 2xx response. |
Request |
createPrack(Response relResponse)
Creates a new PRACK Request message based on a reliable provisional response received by this Dialog and the Dialog internal information. |
Response |
createReliableProvisionalResponse(int statusCode)
Creates a new reliable provisional response based on an Invite request that created this Dialog or that is now refreshing this Dialog. |
Request |
createRequest(java.lang.String method)
Creates a new Request message based on the dialog creating request. |
void |
delete()
This method will release all resources associated with this dialog that are tracked by the SipProvider. |
java.lang.Object |
getApplicationData()
Gets the application specific data specific to this dialog. |
CallIdHeader |
getCallId()
Returns the Call-Id for this dialog. |
java.lang.String |
getDialogId()
Get the dialog identifier of this dialog. |
Transaction |
getFirstTransaction()
Deprecated. Since v1.2. Reduces the amount of state that the stack needs to keep track of. |
Address |
getLocalParty()
Returns the Address identifying the local party. |
long |
getLocalSeqNumber()
The local sequence number is used to order requests from this User Agent Client to its peer User Agent Server. |
int |
getLocalSequenceNumber()
Deprecated. This method is replaced with getLocalSeqNumber() with
type long. |
java.lang.String |
getLocalTag()
Get the Local Tag of this Dialog. |
Address |
getRemoteParty()
Returns the Address identifying the remote party. |
long |
getRemoteSeqNumber()
The remote sequence number is used to order requests from its peer User Agent Client to this User Agent Server. |
int |
getRemoteSequenceNumber()
Deprecated. This method is replaced with getRemoteSeqNumber() with
type long. |
java.lang.String |
getRemoteTag()
Gets the Remote Tag of this Dialog. |
Address |
getRemoteTarget()
Returns the Address identifying the remote target. |
java.util.Iterator |
getRouteSet()
When acting as an User Agent Server the routeset MUST be set to the list of URIs in the Record-Route header field from the request, taken in order and preserving all URI parameters. |
DialogState |
getState()
Returns the current DialogState of the dialog or null. |
void |
incrementLocalSequenceNumber()
This method may be used to increment the local sequence number of the dialog when an application wishes to switch from dialog stateful mode to transaction stateful mode for client transactions and back again to dialog stateful mode. |
boolean |
isSecure()
Returns true if this Dialog is secure, for example if the request was sent over a "sips:" scheme, or a "sip:" scheme over TLS. |
boolean |
isServer()
Returns whether this Dialog is a server dialog, for example this side was initially acting as a UAS. |
void |
sendAck(Request ackRequest)
Sends ACK Request to the remote party of this dialog. |
void |
sendReliableProvisionalResponse(Response relResponse)
Sends a reliable provisional response to the remote party of this dialog. |
void |
sendRequest(ClientTransaction clientTransaction)
Sends a Request to the remote party of this dialog. |
void |
setApplicationData(java.lang.Object applicationData)
Sets application specific data to this dialog. |
void |
terminateOnBye(boolean terminateFlag)
Terminate Dialog on BYE. |
Method Detail |
---|
Address getLocalParty()
This is the value of the To header of received responses in this dialog when acting as an User Agent Server.
Address getRemoteParty()
This is the value of the From header of recieved responses in this dialog when acting as an User Agent Server.
Address getRemoteTarget()
This is the value of the Contact header of received target refresh Requests Requests in this dialog when acting as an User Agent Server.
java.lang.String getDialogId()
CallIdHeader getCallId()
int getLocalSequenceNumber()
getLocalSeqNumber()
with
type long.
Requests within a dialog MUST contain strictly monotonically increasing and contiguous CSeq sequence numbers (increasing-by-one) in each direction (excepting ACK and CANCEL, whose numbers equal the requests being acknowledged or cancelled). Therefore, if the local sequence number is not empty, the value of the local sequence number MUST be incremented by one, and this value MUST be placed into the CSeq header field. If the local sequence number is empty, an initial value MUST be chosen.
getLocalSeqNumber()
long getLocalSeqNumber()
Requests within a dialog MUST contain strictly monotonically increasing and contiguous CSeq sequence numbers (increasing-by-one) in each direction (excepting ACK and CANCEL, whose numbers equal the requests being acknowledged or cancelled). Therefore, if the local sequence number is not empty, the value of the local sequence number MUST be incremented by one, and this value MUST be placed into the CSeq header field. If the local sequence number is empty, an initial value MUST be chosen.
int getRemoteSequenceNumber()
getRemoteSeqNumber()
with
type long.
If the remote sequence number is empty, it MUST be set to the value of the sequence number in the CSeq header field value in the request. If the remote sequence number was not empty, but the sequence number of the request is lower than the remote sequence number, the request is out of order and MUST be rejected with a 500 (Server Internal Error) response. If the remote sequence number was not empty, and the sequence number of the request is greater than the remote sequence number, the request is in order.
getRemoteSeqNumber()
long getRemoteSeqNumber()
If the remote sequence number is empty, it MUST be set to the value of the sequence number in the CSeq header field value in the request. If the remote sequence number was not empty, but the sequence number of the request is lower than the remote sequence number, the request is out of order and MUST be rejected with a 500 (Server Internal Error) response. If the remote sequence number was not empty, and the sequence number of the request is greater than the remote sequence number, the request is in order.
java.util.Iterator getRouteSet()
Requests within a dialog MAY contain Record-Route and Contact header fields. However, these requests do not cause the dialog's route set to be modified.
The User Agent Client uses the remote target and route set to build the Request-URI and Route header field of the request.
boolean isSecure()
true
if this dialog was secure, and
false
otherwise.boolean isServer()
true
if this is a server dialog and
false
if it is a client dialog.void incrementLocalSequenceNumber()
ClientTransaction.sendRequest()
method. When sending a request
using the Transaction the Dialog state is unaffected.
Request createRequest(java.lang.String method) throws SipException
sendRequest(ClientTransaction)
method. Therefore any
Request created by this method must be sent via the
sendRequest(ClientTransaction)
method and not via its
ClientTransaction.sendRequest()
method.
All other headers including any Authentication related headers, and record route headers should be assigned by the application to the generated request. The assignment of the topmost via header for the outgoing request may be deferred until the application creates a ClientTransaction to send the request out. This method does not increment the dialog sequence number. This method may not be used for creating PRACK or ACK. Implementations should throw SipException if this method is called for creating ACK or PRACK.
method
- the string value that determines if the request to be created.
SipException
- if the Dialog is not yet established (i.e. dialog state
equals null) or is terminated or if the method is invoked for
ACK or PRACK.Response createReliableProvisionalResponse(int statusCode) throws InvalidArgumentException, SipException
sendReliableProvisionalResponse( Response)
method.
statusCode
- the new integer of the statusCode value of this Message.
InvalidArgumentException
- when an invalid status code or request method is supplied.
SipException
- when the Dialog is not a server dialog or if this
method is called after a final response is sent to the
ServerTransactin that created the Dialog.void sendRequest(ClientTransaction clientTransaction) throws TransactionDoesNotExistException, SipException
SipProvider.getNewClientTransaction(Request)
. This
ClientTransaction is passed to this method to send the request. The
Request message gets sent via the ListeningPoint information of the
SipProvider that is associated to this ClientTransaction.
This method implies that the application is functioning as UAC hence the underlying SipProvider acts statefully. This method is useful for sending Bye's to terminate a dialog or Re-Invites/Refers on the Dialog for third party call control, call hold etc.
This method will set the From and the To tags for the outgoing request. This method increments the dialog sequence number and sets the correct sequence number to the outgoing Request and associates the client transaction with this dialog. Note that any tags assigned by the user will be over-written by this method. If the caller sets no RouteHeader in the Request to be sent out, the implementation of this method will add the RouteHeader from the routes that are mantained in the dialog. If the caller sets the RouteHeader's, the implementation will leave the route headers unaltered. This allows the application to manage its own route set if so desired.
The User Agent traditionally must not send a BYE on a confirmed INVITE until it has received an ACK for its 2xx response or until the server transaction timeout is received.
A Dialog may be created by an INVITE request and subsequently
SUBSCRIBE/NOTIFY are sent withing that Dialog. In this case the
application may call terminateOnBye(boolean)
to prevent the Dialog
from Terminating upon reciept of a BYE.
clientTransaction
- -
the new ClientTransaction object identifying this transaction,
this clientTransaction should be requested from
SipProvider.getNewClientTransaction(Request)
TransactionDoesNotExistException
- if the clientTransaction does not correspond to any existing
client transaction.
SipException
- if implementation cannot send the Request for any reason.void sendReliableProvisionalResponse(Response relResponse) throws SipException
createReliableProvisionalResponse(int)
. This Response is
passed to this method that sends it. This method will update the RSeq
header of the response if needed and will increase the RSeq count of the
Transaction. The application will not be able to send further reliable
provisional responses for this Dialog until PRACK is received for a
previously sent provisional response. The only response that can be sent
in parallel with an active reliable Provisional Response is a final
response. The Final response will stop retransmission of the reliable
responses.
relResponse
- -
the reliable provisional response
SipException
- if implementation cannot send the Request for any reason
(e.g. because another reliable response is still pending).Request createPrack(Response relResponse) throws DialogDoesNotExistException, SipException
sendRequest(ClientTransaction)
method. Therefore any
Request created by this method must be sent via the
sendRequest(ClientTransaction)
method and not via its
ClientTransaction.sendRequest()
method.
All other headers including any Authentication related headers, and record route headers should be assigned by the application to the generated request. The assignment of the topmost via header for the outgoing request may be deferred until the application creates a ClientTransaction to send the request out. This method does not increment the dialog sequence number.
relResponse
- the reliable provisional response that should result in a
prack reques.
SipException
- if the Method of the transaction that created the Dialog or
Refeshing the Dialog is not an INVITE ( for example
SUBSCRIBE).
DialogDoesNotExistException
- if the Dialog is not yet established (i.e. dialog state
equals null) or is terminated.Request createAck(long cseq) throws InvalidArgumentException, SipException
cseq
- -
the CSeq number to be placed in the ACK request.
InvalidArgumentException
- if there is a problem with the supplied cseq ( for example <=
0 ).
SipException
- if the cseq does not relate to a previously sent INVITE or if
the Method that created the Dialog is not an INVITE ( for
example SUBSCRIBE)void sendAck(Request ackRequest) throws SipException
ackRequest
- -
the new ACK Request message to send.
SipException
- if implementation cannot send the ACK Request for any reasonDialogState getState()
DialogState
void delete()
Transaction getFirstTransaction()
isServer()
.
java.lang.String getLocalTag()
java.lang.String getRemoteTag()
void setApplicationData(java.lang.Object applicationData)
applicationData
- the new object containing application specific data.java.lang.Object getApplicationData()
void terminateOnBye(boolean terminateFlag) throws SipException
delete()
function when all active subscriptions are
terminated.
terminateFlag
- --
if true then the dialog is terminated when a BYE is received.
SipException
- --
if the dialog is already terminated.
|
JSIP API v1.2 November 2006 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |