MjSip Stack
v1.6

org.zoolu.sip.dialog
Class InviteDialog

java.lang.Object
  |
  +--org.zoolu.sip.dialog.DialogInfo
        |
        +--org.zoolu.sip.dialog.Dialog
              |
              +--org.zoolu.sip.dialog.InviteDialog
All Implemented Interfaces:
AckTransactionServerListener, InviteTransactionServerListener, SipProviderListener, TransactionClientListener, TransactionServerListener
Direct Known Subclasses:
ExtendedInviteDialog

public class InviteDialog
extends Dialog
implements TransactionClientListener, InviteTransactionServerListener, AckTransactionServerListener, SipProviderListener

Class InviteDialog can be used to manage invite dialogs. An InviteDialog can be both client or server. (i.e. generating an INVITE request or responding to an incoming INVITE request).

An InviteDialog can be in state inviting/waiting/invited, accepted/refused, call, byed/byeing, and close.

InviteDialog supports the offer/answer model for the sip body, with the following rules:
- both INVITE-offer/2xx-answer and 2xx-offer/ACK-answer modes for incoming calls
- INVITE-offer/2xx-answer mode for outgoing calls.


Field Summary
protected static int D_ACCEPTED
           
protected static int D_BYED
           
protected static int D_BYEING
           
protected static int D_CALL
           
protected static int D_CLOSE
           
protected static int D_INIT
           
protected static int D_INVITED
           
protected static int D_INVITING
           
protected static int D_ReACCEPTED
           
protected static int D_REFUSED
           
protected static int D_ReINVITED
           
protected static int D_ReINVITING
           
protected static int D_ReREFUSED
           
protected static int D_ReWAITING
           
protected static int D_WAITING
           
 
Fields inherited from class org.zoolu.sip.dialog.Dialog
dialog_id, dialog_sqn, log, sip_provider, status, UAC, UAS
 
Constructor Summary
InviteDialog(SipProvider sip_provider, InviteDialogListener listener)
          Creates a new InviteDialog.
InviteDialog(SipProvider sip_provider, Message invite, InviteDialogListener listener)
          Creates a new InviteDialog for the already received INVITE request invite.
 
Method Summary
 void accept(java.lang.String contact, java.lang.String sdp)
          Accepts the incoming call.
 void ackWithAnswer(Message ack)
          Sends the ack when offer/answer is in 2xx/ack
 void ackWithAnswer(java.lang.String contact, java.lang.String session_descriptor)
          Sends the ack when offer/answer is in 2xx/ack
 void bye()
          Termiante the call.
 void bye(Message bye)
          Termiante the call.
 void cancel()
          Cancel the ongoing call request or a call listening.
 void cancel(Message cancel)
          Cancel the ongoing call request or a call listening.
 Message getInviteMessage()
          Gets the invite message
protected  java.lang.String getStatus()
          Gets the dialog state
 void invite(Message invite)
          Starts a new InviteTransactionClient and initializes the dialog state information
 void invite(java.lang.String callee, java.lang.String caller, java.lang.String contact, java.lang.String session_descriptor)
          Starts a new InviteTransactionClient and initializes the dialog state information.
 void inviteWithoutOffer(Message invite)
          Starts a new InviteTransactionClient with offer/answer in 2xx/ack and initializes the dialog state information
 void inviteWithoutOffer(java.lang.String callee, java.lang.String caller, java.lang.String contact)
          Starts a new InviteTransactionClient with offer/answer in 2xx/ack and initializes the dialog state information
 boolean isConfirmed()
          Whether the dialog is in "confirmed" state.
 boolean isEarly()
          Whether the dialog is in "early" state.
 boolean isSessionActive()
          Whether the session is "active".
 boolean isTerminated()
          Whether the dialog is in "terminated" state.
 void listen()
          Starts a new InviteTransactionServer.
 void onReceivedMessage(SipProvider sip_provider, Message msg)
          Inherited from class SipProviderListener.
 void onTransAckTimeout(AckTransactionServer ts)
          When the AckTransactionServer goes into the "Terminated" state, caused by transaction timeout
 void onTransFailureAck(InviteTransactionServer ts, Message msg)
          Inherited from InviteTransactionServerListener.
 void onTransFailureResponse(TransactionClient tc, Message msg)
          Inherited from TransactionClientListener.
 void onTransProvisionalResponse(TransactionClient tc, Message msg)
          Inherited from TransactionClientListener.
 void onTransRequest(TransactionServer ts, Message req)
          Inherited from TransactionServerListener.
 void onTransSuccessResponse(TransactionClient tc, Message msg)
          Inherited from TransactionClientListener.
 void onTransTimeout(TransactionClient tc)
          Inherited from TransactionClientListener.
protected  void printLog(java.lang.String str, int level)
          Adds a new string to the default Log
 void redirect(int code, java.lang.String reason, java.lang.String contact)
          Redirects the incoming call , specifing the code and reason.
 void refuse()
          Refuses the incoming call.
 void refuse(int code, java.lang.String reason)
          Refuses the incoming call.
 void reInvite(Message invite)
          Re-invites the remote user.
 void reInvite(java.lang.String contact, java.lang.String session_descriptor)
          Re-invites the remote user.
 void reInviteWithoutOffer(Message invite)
          Re-invites the remote user with offer/answer in 2xx/ack Starts a new InviteTransactionClient and changes the dialog state information
 void reInviteWithoutOffer(java.lang.String contact, java.lang.String session_descriptor)
          Re-invites the remote user with offer/answer in 2xx/ack Starts a new InviteTransactionClient and changes the dialog state information
 void respond(int code, java.lang.String reason, java.lang.String contact, java.lang.String sdp)
          Responds with code and reason.
 void respond(Message resp)
          Responds with resp.
 void ring()
          Signals that the phone is ringing.
 
Methods inherited from class org.zoolu.sip.dialog.Dialog
changeStatus, getDialogID, getSipProvider, printException, printWarning, statusIs, update, verifyStatus, verifyThat
 
Methods inherited from class org.zoolu.sip.dialog.DialogInfo
getCallID, getLocalContact, getLocalCSeq, getLocalName, getLocalTag, getRemoteContact, getRemoteCSeq, getRemoteName, getRemoteTag, getRoute, incLocalCSeq, incRemoteCSeq, setCallID, setLocalContact, setLocalCSeq, setLocalName, setLocalTag, setRemoteContact, setRemoteCSeq, setRemoteName, setRemoteTag, setRoute
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

D_INIT

protected static final int D_INIT

D_WAITING

protected static final int D_WAITING

D_INVITING

protected static final int D_INVITING

D_INVITED

protected static final int D_INVITED

D_REFUSED

protected static final int D_REFUSED

D_ACCEPTED

protected static final int D_ACCEPTED

D_CALL

protected static final int D_CALL

D_ReWAITING

protected static final int D_ReWAITING

D_ReINVITING

protected static final int D_ReINVITING

D_ReINVITED

protected static final int D_ReINVITED

D_ReREFUSED

protected static final int D_ReREFUSED

D_ReACCEPTED

protected static final int D_ReACCEPTED

D_BYEING

protected static final int D_BYEING

D_BYED

protected static final int D_BYED

D_CLOSE

protected static final int D_CLOSE
Constructor Detail

InviteDialog

public InviteDialog(SipProvider sip_provider,
                    InviteDialogListener listener)
Creates a new InviteDialog.

InviteDialog

public InviteDialog(SipProvider sip_provider,
                    Message invite,
                    InviteDialogListener listener)
Creates a new InviteDialog for the already received INVITE request invite.
Method Detail

getStatus

protected java.lang.String getStatus()
Gets the dialog state
Overrides:
getStatus in class Dialog

isEarly

public boolean isEarly()
Whether the dialog is in "early" state.
Overrides:
isEarly in class Dialog

isConfirmed

public boolean isConfirmed()
Whether the dialog is in "confirmed" state.
Overrides:
isConfirmed in class Dialog

isTerminated

public boolean isTerminated()
Whether the dialog is in "terminated" state.
Overrides:
isTerminated in class Dialog

isSessionActive

public boolean isSessionActive()
Whether the session is "active".

getInviteMessage

public Message getInviteMessage()
Gets the invite message

listen

public void listen()
Starts a new InviteTransactionServer.

invite

public void invite(java.lang.String callee,
                   java.lang.String caller,
                   java.lang.String contact,
                   java.lang.String session_descriptor)
Starts a new InviteTransactionClient and initializes the dialog state information.
Parameters:
callee - the callee url (and display name)
caller - the caller url (and display name)
contact - the contact url OR the contact username
session_descriptor - SDP body

invite

public void invite(Message invite)
Starts a new InviteTransactionClient and initializes the dialog state information
Parameters:
invite - the INVITE message

inviteWithoutOffer

public void inviteWithoutOffer(java.lang.String callee,
                               java.lang.String caller,
                               java.lang.String contact)
Starts a new InviteTransactionClient with offer/answer in 2xx/ack and initializes the dialog state information

inviteWithoutOffer

public void inviteWithoutOffer(Message invite)
Starts a new InviteTransactionClient with offer/answer in 2xx/ack and initializes the dialog state information

reInvite

public void reInvite(java.lang.String contact,
                     java.lang.String session_descriptor)
Re-invites the remote user.

Starts a new InviteTransactionClient and changes the dialog state information

Parameters:
- contact : the contact url OR the contact username; if null, the previous contact is used
- session_descriptor : the message body


reInvite

public void reInvite(Message invite)
Re-invites the remote user.

Starts a new InviteTransactionClient and changes the dialog state information


reInviteWithoutOffer

public void reInviteWithoutOffer(Message invite)
Re-invites the remote user with offer/answer in 2xx/ack

Starts a new InviteTransactionClient and changes the dialog state information


reInviteWithoutOffer

public void reInviteWithoutOffer(java.lang.String contact,
                                 java.lang.String session_descriptor)
Re-invites the remote user with offer/answer in 2xx/ack

Starts a new InviteTransactionClient and changes the dialog state information


ackWithAnswer

public void ackWithAnswer(java.lang.String contact,
                          java.lang.String session_descriptor)
Sends the ack when offer/answer is in 2xx/ack

ackWithAnswer

public void ackWithAnswer(Message ack)
Sends the ack when offer/answer is in 2xx/ack

respond

public void respond(Message resp)
Responds with resp. This method can be called when the InviteDialog is in D_INVITED or D_BYED states.

If the CSeq method is INVITE and the response is 2xx, it moves to state D_ACCEPTED, adds a new listener to the SipProviderListener, and creates new AckTransactionServer

If the CSeq method is INVITE and the response is not 2xx, it moves to state D_REFUSED, and sends the response.


respond

public void respond(int code,
                    java.lang.String reason,
                    java.lang.String contact,
                    java.lang.String sdp)
Responds with code and reason. This method can be called when the InviteDialog is in D_INVITED, D_ReINVITED states

ring

public void ring()
Signals that the phone is ringing. This method should be called when the InviteDialog is in D_INVITED or D_ReINVITED state

accept

public void accept(java.lang.String contact,
                   java.lang.String sdp)
Accepts the incoming call. This method should be called when the InviteDialog is in D_INVITED or D_ReINVITED state

refuse

public void refuse(int code,
                   java.lang.String reason)
Refuses the incoming call. This method should be called when the InviteDialog is in D_INVITED or D_ReINVITED state

refuse

public void refuse()
Refuses the incoming call. This method should be called when the InviteDialog is in D_INVITED or D_ReINVITED state

bye

public void bye()
Termiante the call. This method should be called when the InviteDialog is in D_CALL state

Increments the Cseq, moves to state D_BYEING, and creates new BYE TransactionClient


bye

public void bye(Message bye)
Termiante the call. This method should be called when the InviteDialog is in D_CALL state

Increments the Cseq, moves to state D_BYEING, and creates new BYE TransactionClient


cancel

public void cancel()
Cancel the ongoing call request or a call listening. This method should be called when the InviteDialog is in D_INVITING or D_ReINVITING state or in the D_WAITING state

cancel

public void cancel(Message cancel)
Cancel the ongoing call request or a call listening. This method should be called when the InviteDialog is in D_INVITING or D_ReINVITING state or in the D_WAITING state

redirect

public void redirect(int code,
                     java.lang.String reason,
                     java.lang.String contact)
Redirects the incoming call , specifing the code and reason. This method can be called when the InviteDialog is in D_INVITED or D_ReINVITED state

onReceivedMessage

public void onReceivedMessage(SipProvider sip_provider,
                              Message msg)
Inherited from class SipProviderListener. Called when a new message is received (out of any ongoing transaction) for the current InviteDialog. Always checks for out-of-date methods (CSeq header sequence number).

If the message is ACK(2xx/INVITE) request, it moves to D_CALL state, and fires onDlgAck(this,body,msg).

If the message is 2xx(INVITE) response, it create a new AckTransactionClient

If the message is BYE, it moves to D_BYED state, removes the listener from SipProvider, fires onDlgBye(this,msg) then it responds with 200 OK, moves to D_CLOSE state and fires onDlgClose(this)

Specified by:
onReceivedMessage in interface SipProviderListener
Overrides:
onReceivedMessage in class Dialog

onTransProvisionalResponse

public void onTransProvisionalResponse(TransactionClient tc,
                                       Message msg)
Inherited from TransactionClientListener. When the TransactionClientListener is in "Proceeding" state and receives a new 1xx response

For INVITE transaction it fires onFailureResponse(this,code,reason,body,msg).

Specified by:
onTransProvisionalResponse in interface TransactionClientListener

onTransFailureResponse

public void onTransFailureResponse(TransactionClient tc,
                                   Message msg)
Inherited from TransactionClientListener. When the TransactionClientListener goes into the "Completed" state, receiving a failure response

If called for a INVITE transaction, it moves to D_CLOSE state, removes the listener from SipProvider.

If called for a BYE transaction, it moves to D_CLOSE state, removes the listener from SipProvider, and fires onClose(this,msg).

Specified by:
onTransFailureResponse in interface TransactionClientListener

onTransSuccessResponse

public void onTransSuccessResponse(TransactionClient tc,
                                   Message msg)
Inherited from TransactionClientListener. When an TransactionClientListener goes into the "Terminated" state, receiving a 2xx response

If called for a INVITE transaction, it updates the dialog information, moves to D_CALL state, add a listener to the SipProvider, creates a new AckTransactionClient(ack,this), and fires onSuccessResponse(this,code,body,msg).

If called for a BYE transaction, it moves to D_CLOSE state, removes the listener from SipProvider, and fires onClose(this,msg).

Specified by:
onTransSuccessResponse in interface TransactionClientListener

onTransTimeout

public void onTransTimeout(TransactionClient tc)
Inherited from TransactionClientListener. When the TransactionClient goes into the "Terminated" state, caused by transaction timeout
Specified by:
onTransTimeout in interface TransactionClientListener

onTransRequest

public void onTransRequest(TransactionServer ts,
                           Message req)
Inherited from TransactionServerListener. When the TransactionServer goes into the "Trying" state receiving a request

If called for a INVITE transaction, it initializes the dialog information,
moves to D_INVITED state, and add a listener to the SipProvider,
and fires onInvite(caller,body,msg).

Specified by:
onTransRequest in interface TransactionServerListener

onTransFailureAck

public void onTransFailureAck(InviteTransactionServer ts,
                              Message msg)
Inherited from InviteTransactionServerListener. When an InviteTransactionServer goes into the "Confirmed" state receining an ACK for NON-2xx response

It moves to D_CLOSE state and removes the listener from SipProvider.

Specified by:
onTransFailureAck in interface InviteTransactionServerListener

onTransAckTimeout

public void onTransAckTimeout(AckTransactionServer ts)
When the AckTransactionServer goes into the "Terminated" state, caused by transaction timeout
Specified by:
onTransAckTimeout in interface AckTransactionServerListener

printLog

protected void printLog(java.lang.String str,
                        int level)
Adds a new string to the default Log
Overrides:
printLog in class Dialog

MjSip Stack
v1.6