The MIDlet (Listing B.3.1) shows a simplified example of originating side UA in SIP session. The example handles only the SIP signaling in a sequence and does not handle any error cases. The MIDlet implements following things:
Opens a SipConnectionNotifier for incoming requests like BYE and sets itself as a listener
Opens outbound SipClientConnection to the user specified in the MIDlet UI.
Initializes and sends INVITE with attached SDP content
Receives provisional responses 100, 180 until final 200 OK response
(The INVITE can be cancelled by sending CANCEL before the 200 OK has been received.)
Reads SDP content from 200 OK response
Saves the SipDialog information after 200 OK response
Initializes and sends ACK -> session established
Gets new SipClientConnection from SipDialog object
Initializes BYE request and sends it
Receives 200 OK for BYE -> session terminated
Terminating side
This MIDlet (Listing B.3.2) shows an example of terminating side UA in SIP session. The example handles only the SIP signaling in a sequence and does not handle any error cases. The MIDlet does following steps:
Opens inbound SipConnectionNotifier for incoming requests on "sip:5070"
Receives INVITE request and reads the SDP content
Initializes and sends responses 180 and 200 OK, with own SDP content
(The INVITE can be rejected by sending 486 Buzy Here after the 180 Ringing has been sent.)
Waits for other side to send ACK -> session established
Waits for other side to send BYE -> session terminated
B.2.0 Subscribing for presence information
This MIDlet (Listing B.3.3) shows a simplified example of subscribing for presence info. The MIDlet does following things:
Opens inbound SipConnectionNotifier for incoming requests on "sip:5060"
Sets the MIDlet as a listener for events from SipConnectionNotifier
Initializes and sends SUBSCRIBE with additional header information: Expires, Event and Accept
Waits for 200 OK response
Waits 10 seconds before sending un-SUBSCRIBE with "Expires: 0" header
Receives 200 OK for un-SUBSCRIBE in notifyResponse() method
The listener method notifyResponse() handles all NOTIFY requests