Symbian3/SDK/Source/GUID-4120651F-E0B9-5927-96B9-2662C51F5A09.dita
changeset 0 89d6a7a84779
equal deleted inserted replaced
-1:000000000000 0:89d6a7a84779
       
     1 <?xml version="1.0" encoding="utf-8"?>
       
     2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
       
     3 <!-- This component and the accompanying materials are made available under the terms of the License 
       
     4 "Eclipse Public License v1.0" which accompanies this distribution, 
       
     5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
       
     6 <!-- Initial Contributors:
       
     7     Nokia Corporation - initial contribution.
       
     8 Contributors: 
       
     9 -->
       
    10 <!DOCTYPE concept
       
    11   PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
       
    12 <concept id="GUID-4120651F-E0B9-5927-96B9-2662C51F5A09" xml:lang="en"><title>SIP High
       
    13 Level API</title><prolog><metadata><keywords/></metadata></prolog><conbody>
       
    14 <p>The SIP High Level API encapsulates the SIP call flows inside the <xref href="GUID-BED8A733-2ED7-31AD-A911-C1F4707C67FD.dita"><apiname>RConnection</apiname></xref> and <xref href="GUID-0AFDA357-EE44-3788-9CAB-162B874134BF.dita"><apiname>RSubConnection</apiname></xref> APIs.
       
    15 The following SIP functionality is supported using <xref href="GUID-BED8A733-2ED7-31AD-A911-C1F4707C67FD.dita"><apiname>RConnection</apiname></xref> and <xref href="GUID-0AFDA357-EE44-3788-9CAB-162B874134BF.dita"><apiname>RSubConnection</apiname></xref> APIs: </p>
       
    16 <ul>
       
    17 <li id="GUID-0A13EB92-CD3F-5F33-AE9F-3333BDFB5B03"><p>REGISTER - An application
       
    18 that wants to start a SIP session must register to the SIP server. For more
       
    19 information, see <xref href="GUID-4120651F-E0B9-5927-96B9-2662C51F5A09.dita#GUID-4120651F-E0B9-5927-96B9-2662C51F5A09/GUID-02CBB3C7-9B7C-5B49-8F29-56F235FF320E">Registration</xref>. </p> </li>
       
    20 <li id="GUID-63D5BA93-28C1-5CE6-A1AD-78AD21EF5C6F"><p>INVITE - An invite session
       
    21 is created for activities such as setting up a voice call, and a game session.
       
    22 For more information, see <xref href="GUID-4120651F-E0B9-5927-96B9-2662C51F5A09.dita#GUID-4120651F-E0B9-5927-96B9-2662C51F5A09/GUID-EE044B0B-4664-57DA-BAE1-F9A3B99C453C">Session
       
    23 initiation</xref>. </p> </li>
       
    24 <li id="GUID-40206112-EC3B-57EF-B316-F7C938EB2118"><p>SUBSCRIBE - SIP supports
       
    25 subscription to events for example, message waiting, notifying the subscriber
       
    26 about the current state of the event and any changes to its state. For more
       
    27 information, see <xref href="GUID-4120651F-E0B9-5927-96B9-2662C51F5A09.dita#GUID-4120651F-E0B9-5927-96B9-2662C51F5A09/GUID-BF804D44-35A2-5997-9706-B48C2C30F2BE">Initiating
       
    28 a session using SUBSCRIBE</xref>. </p> </li>
       
    29 </ul>
       
    30 <p>The <codeph>INVITE</codeph> and <codeph>SUBSCRIBE</codeph> methods must
       
    31 be registered. <xref href="GUID-A412D2E5-C4BE-33F7-A610-ECBD1BD6BBF9.dita"><apiname>CSubConSIPInviteParamSet</apiname></xref> and <xref href="GUID-8ABE119B-CF5D-3FED-A26F-E889AE6B7663.dita"><apiname>CSubConSIPSubscribeParamSet</apiname></xref> classes
       
    32 provide the parameters. </p>
       
    33 <p> <b>Note</b>: SIP High Level API is included in the Symbian OS from version
       
    34 9.2 onwards. </p>
       
    35 <section id="GUID-02CBB3C7-9B7C-5B49-8F29-56F235FF320E"><title>Registration</title> <p>An
       
    36 endpoint, for example a SIP enabled phone, that wants to start a SIP session
       
    37 must use <xref href="GUID-BED8A733-2ED7-31AD-A911-C1F4707C67FD.dita"><apiname>RConnection</apiname></xref> to register with the SIP registrar.
       
    38 For more information about RConnection, see<xref href="GUID-BD8446C5-3ADE-59A6-A13A-A5482D6FC56F.dita">Connection
       
    39 Management</xref> . <xref href="GUID-506C0ECB-9424-3579-877E-1435F76B2594.dita"><apiname>ESOCK</apiname></xref> provides an interface for the
       
    40 user to access the SIP high level API. <xref href="GUID-506C0ECB-9424-3579-877E-1435F76B2594.dita"><apiname>ESOCK</apiname></xref> interacts
       
    41 with the SIP high level API through the <codeph>Connection</codeph> and <codeph>SubConnection</codeph> providers.
       
    42 Connection and SubConnection providers are <codeph>ESOCK</codeph> server side
       
    43 components that are loaded and called when <xref href="GUID-BED8A733-2ED7-31AD-A911-C1F4707C67FD.dita"><apiname>RConnection</apiname></xref> and <xref href="GUID-0AFDA357-EE44-3788-9CAB-162B874134BF.dita"><apiname>RSubConnection</apiname></xref> APIs
       
    44 are used. </p> <p>The following figure shows the architectural layer where
       
    45 the application interacts with SIP connection providers using SIPPARAMS. The
       
    46 second layer comprising <xref href="GUID-D4F08503-F1EF-3531-9C3C-4AF24A6255F0.dita"><apiname>RSocket</apiname></xref>, <xref href="GUID-0AFDA357-EE44-3788-9CAB-162B874134BF.dita"><apiname>RSubConnection</apiname></xref>,
       
    47 and <xref href="GUID-BED8A733-2ED7-31AD-A911-C1F4707C67FD.dita"><apiname>RConnection</apiname></xref> constitute the SIPPARAMS. </p> <fig id="GUID-57FDC30F-E5AD-5C9D-8D80-71B35CB905D4">
       
    48 <title>              Interface of Connection and Sub Connection.         
       
    49   </title>
       
    50 <image href="GUID-FFE6BAF8-C093-53FC-8672-365BAF38E048_d0e318604_href.png" placement="inline"/>
       
    51 </fig> <p>The SIP high level API models the SIP with Connection and SubConnection
       
    52 providers and makes it stackable against the unified comms-infras architecture.
       
    53 This enables the future connection convergence. </p> <p><b> Initial setup</b> </p> <p>A
       
    54 profile data store is required to get registered with the SIP Registrar. A
       
    55 SIP registration profile is a data store containing the information required
       
    56 for registration such as AOR which is the IP address of registrar. The data
       
    57 profile must contain the following fields: </p> <ul>
       
    58 <li id="GUID-9419A4E2-40DB-52E4-9B70-89DEF5594CF6"><p>data profile type: Internet,
       
    59 IMS, others </p> </li>
       
    60 <li id="GUID-36207215-4ECE-5D08-AEFB-6D801DBA0902"><p>profile name IETF, IMS,
       
    61 others </p> </li>
       
    62 <li id="GUID-FF904FF9-9D4B-5B34-986F-8F565BDE8E41"><p>IAP name </p> </li>
       
    63 <li id="GUID-C66C0664-B9A8-59C8-8C44-88634D7D2E94"><p>profile AOR list (IP
       
    64 address) </p> </li>
       
    65 <li id="GUID-D85CF1F0-98CA-5947-90EB-0C4D0B96EBCC"><p>autoregistration </p> </li>
       
    66 <li id="GUID-FC499704-39DC-55E1-80EC-3A3F8F0A8C53"><p>private ID </p> </li>
       
    67 <li id="GUID-ED9C3D8E-A8CC-5D65-B381-81EC51264980"><p>security negotiation </p> </li>
       
    68 <li id="GUID-B400C58A-E180-54B7-A536-7B7103CD4274"><p>sigcomp </p> </li>
       
    69 <li id="GUID-AB1D459F-CCEA-5D20-8FCE-02939F716093"><p>server (IP address of
       
    70 registrar, outbound proxy) </p> </li>
       
    71 <li id="GUID-999CAACE-4E8F-5EDA-877E-2A46580D9BA9"><p>server param (username,
       
    72 realm, pwd) </p> </li>
       
    73 <li id="GUID-B4AAE1EE-1A67-5FBE-8F75-9BCB01E2ECE2"><p>default </p> </li>
       
    74 </ul> <p>Manual registration by specifying parameters is not possible. If
       
    75 connection details are not available, the connection is set up using the default <filepath>profile.flag</filepath> file. </p> <p id="GUID-D17BC438-09C2-58E9-ABE8-F18B8A285B4D"><b>Creating an RConnection</b> </p> <p>Create
       
    76 an <xref href="GUID-BED8A733-2ED7-31AD-A911-C1F4707C67FD.dita"><apiname>RConnection</apiname></xref> to register to the SIP Registrar using the
       
    77 following steps. <xref href="GUID-BED8A733-2ED7-31AD-A911-C1F4707C67FD.dita"><apiname>RConnection</apiname></xref> must be opened on an existing
       
    78 socket server session, <xref href="GUID-EF29C1D7-B1E5-370F-AE37-66231A6BE449.dita"><apiname>RSocketServ</apiname></xref>. </p> <codeblock id="GUID-AC8B369E-1DC8-5868-95E2-B09FCFE4987E" xml:space="preserve">RSocketServ    socketServer;        // Create a client interface object to the socket server
       
    79 RConnection    con;                        // Create an RConnection object
       
    80 TRequestStatus status = KErrNone;                // object to hold the request completion status
       
    81 
       
    82 // Establish the connection to the Socket server
       
    83 
       
    84 User::LeaveIfError(socketServer.Connect());        // Returns KErrorNone if the connection is successful
       
    85 CleanupClosePushL(socketServer);
       
    86 
       
    87 TUint KAFSip = 0x10000;             //SIP protocol family id
       
    88 TInt err = con.Open (socketServer,KAFSip);            //open the connection
       
    89 TInt err1 = con.Start();                    // Start Rconnection to initiate the registration
       
    90 </codeblock> <p>When registration to the SIP registrar is successful, <xref href="GUID-0AFDA357-EE44-3788-9CAB-162B874134BF.dita"><apiname>RSubConnection</apiname></xref> is
       
    91 used to establish the SIP Invite or SIP Subscribe session. The <xref href="GUID-BED8A733-2ED7-31AD-A911-C1F4707C67FD.dita"><apiname>RConnection</apiname></xref> and <xref href="GUID-0AFDA357-EE44-3788-9CAB-162B874134BF.dita"><apiname>RSubConnection</apiname></xref> that
       
    92 is established and opened are used for either inviting a call session or subscribing
       
    93 for the message status. </p> </section>
       
    94 <section id="GUID-565742FA-20AB-57A8-AB81-19664F9B2BC8"><title>Session initiation</title> <p><b>SIP
       
    95 Params</b> </p> <p>SIPPARAMS is used to simplify the interaction with the
       
    96 SIP stack by abstracting the SIP functionality using the <xref href="GUID-BED8A733-2ED7-31AD-A911-C1F4707C67FD.dita"><apiname>RConnection</apiname></xref> and <xref href="GUID-0AFDA357-EE44-3788-9CAB-162B874134BF.dita"><apiname>RSubConnection</apiname></xref> APIs.  It
       
    97 supports the basic SIP functionality. The complete SIP functionality is made
       
    98 available through the SIP stack APIs. </p> <p id="GUID-EE044B0B-4664-57DA-BAE1-F9A3B99C453C"><b>Initiating
       
    99 a session using INVITE</b> </p> <p> <xref href="GUID-0AFDA357-EE44-3788-9CAB-162B874134BF.dita"><apiname>RSubConnection</apiname></xref> is used
       
   100 to establish a SIP Invite session. A SIP invitation starts when an endpoint
       
   101 such as a VoIP Softphone or VoIP Hardware tries to establish a session with
       
   102 a remote compliant endpoint. A successful SIP invitation consists of an INVITE-OK-ACK
       
   103 triplet message exchange. The calling endpoint tries to start a session with
       
   104 SIP INVITE. This is followed by OK from the called endpoint, and by ACK from
       
   105 the calling endpoint that finally establishes the SIP session. </p> <p>A SIP
       
   106 session can be terminated by using BYE-200OK message exchange. Either the
       
   107 calling or the called party can initiate the termination. </p> <p> <xref href="GUID-0AFDA357-EE44-3788-9CAB-162B874134BF.dita"><apiname>RSubConnection</apiname></xref> establishes
       
   108 the SIP session using the three way communication of INVITE-OK-ACK and terminates
       
   109 the call using BYE-200OK. </p> <p> <xref href="GUID-0AFDA357-EE44-3788-9CAB-162B874134BF.dita"><apiname>RSubConnection</apiname></xref> when
       
   110 used on behalf of the calling endpoint, handles the message exchange independently
       
   111 and provides the status whether the session is established, denied or not
       
   112 reachable. The calling endpoint must fill the necessary SIP session parameters
       
   113 that are used to determine the target. </p> <p> <xref href="GUID-0AFDA357-EE44-3788-9CAB-162B874134BF.dita"><apiname>RSubConnection</apiname></xref> when
       
   114 used on behalf of the called endpoint alerts the user of an incoming call
       
   115 such as a SIP invitation. The incoming call can be either accepted or rejected
       
   116 using <xref href="GUID-0AFDA357-EE44-3788-9CAB-162B874134BF.dita"><apiname>RSubConnection</apiname></xref>. The application is notified about
       
   117 the outcome. The information about the calling endpoint is provided in a set
       
   118 of specific parameters. </p> <p>The SIP parameters for an outgoing call is
       
   119 set using <xref href="GUID-A412D2E5-C4BE-33F7-A610-ECBD1BD6BBF9.dita"><apiname>CSubConSIPInviteParamSet</apiname></xref> class. The following
       
   120 code shows how to initiate a call. It is assumed that you have already registered
       
   121 with the SIP registrar by creating an <codeph>RConnection</codeph> object
       
   122 and called <codeph>Open()</codeph>. For more information, see <xref href="GUID-4120651F-E0B9-5927-96B9-2662C51F5A09.dita#GUID-4120651F-E0B9-5927-96B9-2662C51F5A09/GUID-D17BC438-09C2-58E9-ABE8-F18B8A285B4D">Creating an RConnection</xref>. </p> <codeblock id="GUID-0DCB4778-33E7-5604-A7C4-ED534B48FA33" xml:space="preserve">RSubConnection    subCon;    // Create an RSubConnection object
       
   123 err=subCon.Open(socketServer,RSubConnection::ECreateNew,con); // Open subconnection onto the Rconnection
       
   124 </codeblock> <p>Set the SIP Invite parameters. The following code shows how
       
   125 to set the SIP Invite parameters. </p> <codeblock id="GUID-904E8A67-646D-5589-9144-60D4C2598A62" xml:space="preserve">RSubConParameterBundle     sipBundle;            // create parameter bundle
       
   126 
       
   127 // create SIP parameter set family
       
   128 CSubConParameterFamily * family = CSubConParameterFamily::NewL(sipBundle,KSubConnCallDescrParamsFamily);
       
   129 
       
   130 // create invite parameter set object
       
   131 CSubConSIPInviteParamSet* sip = CSubConSIPInviteParamSet::NewL(*family,CSubConParameterFamily::ERequested);</codeblock> <p>Set
       
   132 the SIP header values to the parameter set. The following code shows how to
       
   133 set the SIP header values to the parameter set. </p> <codeblock id="GUID-E298FDDC-28CE-506D-A301-B5F04DC7D7AD" xml:space="preserve">_LIT8(KTo,"Sip:user@10.112.165.91");        //'To' header, SIP URI of called endpoint
       
   134 TPtrC8 ptrTo(KTo());
       
   135 sip-&gt;SetToL(ptrTo);         //Set'To', the target SIP URI to the SIP parameter set
       
   136 
       
   137 _LIT8(KFrom, "Sip:user@10.112.165.62");        //'From' header, SIP URI of the calling endPoint
       
   138 TPtrC8 ptrFrom(KFrom());
       
   139 sip-&gt;SetFromL(ptrFrom);                //Set the 'From' header field to the SIP parameter set
       
   140 
       
   141 _LIT8(KContact,"Sip:user@10.112.165.62");            //'Contact' header, the actual location of the calling endpoint
       
   142 TPtrC8 ptrContact (KContact());
       
   143 sip-&gt;SetContactL(ptrContact);                //Set the 'Contact' to the SIP parameter set 
       
   144 
       
   145 _LIT8(KRequestUri, "Sip:user@10.112.165.91");    //Request URI, the actual Next hop or the Target
       
   146 TPtrC8 ptrRequestUri(KRequestUri());
       
   147 sip-&gt;SetRequestUriL(ptrRequestUri);             //Set the 'RequestUri' to the SIP parameter set</codeblock> <codeblock id="GUID-916B4C73-B97B-5EC0-A70E-EFDD0FB51210" xml:space="preserve">TInt err = SubCon.SetParameters(sipBundle);         //Set The SIP parameters in the SubConnection
       
   148 sipBundle.Close();                    //close the parameter bundle</codeblock> <p id="GUID-8676EB5B-FA5D-51EC-9FAD-C36BB29A6392"><b>Establishing the INVITE
       
   149 session</b> </p> <p>To establish the SIP Invite session, use <xref href="GUID-0AFDA357-EE44-3788-9CAB-162B874134BF.dita"><apiname>RSubConnection</apiname></xref> to
       
   150 start the subconnection. This initiates the Invite request. </p> <codeblock id="GUID-4A8E0FB2-7096-583F-9DF6-D0B2255F618A" xml:space="preserve">//Start the subconnection, effectively sending an Invite
       
   151 TInt subConRet = subCon.Start(); 
       
   152 // Session is established</codeblock> <p id="GUID-BF804D44-35A2-5997-9706-B48C2C30F2BE"><b>Initiating
       
   153 a session using SUBSCRIBE</b> </p> <p>An endpoint subscribes to a specific
       
   154 service using a SIP SUBSCRIBE-200OK message exchange. The end point is notified
       
   155 by means of a NOTIFY-200OK message exchange. To send the subscription and
       
   156 receive notifications use <xref href="GUID-0AFDA357-EE44-3788-9CAB-162B874134BF.dita"><apiname>RSubConnection</apiname></xref>. <xref href="GUID-0AFDA357-EE44-3788-9CAB-162B874134BF.dita"><apiname>RSubConnection</apiname></xref> is
       
   157 also used to unsubscribe, which stops any further notifications. </p> <p>The
       
   158 following code shows how you subscribe to a session and receive notifications.
       
   159 It assumes that you have already registered with the SIP registrar by creating
       
   160 an <codeph>RConnection</codeph> object and calling <codeph>Open()</codeph> on
       
   161 it as explained in <xref href="GUID-4120651F-E0B9-5927-96B9-2662C51F5A09.dita#GUID-4120651F-E0B9-5927-96B9-2662C51F5A09/GUID-D17BC438-09C2-58E9-ABE8-F18B8A285B4D">Creating
       
   162 an RConnection</xref> section. </p> <codeblock id="GUID-B68FF753-0D48-54C2-8DE1-282658CE96BA" xml:space="preserve">RSubConnection    subCon;// Create an RSubConnection object
       
   163 // Open subconnection onto the Rconnection
       
   164 err=subCon.Open(socketServer,RSubConnection::ECreateNew,con);
       
   165 </codeblock> <p>Set the SIP Subscribe parameters using <xref href="GUID-8ABE119B-CF5D-3FED-A26F-E889AE6B7663.dita"><apiname>CSubConSIPSubscribeParamSet</apiname></xref>.
       
   166 This class provides the SIP subscribe parameters that are passed through the
       
   167 subconnection to the SIP stack. </p> <codeblock id="GUID-3512DB0A-EE9E-5B59-92D5-46F65CB9F4B4" xml:space="preserve">RSubConParameterBundle     sipBundle;                 //    create parameter bundle
       
   168 
       
   169 //create SIP parameter set family
       
   170 CSubConParameterFamily * family = CSubConParameterFamily::NewL(sipBundle,KSubConnCallDescrParamsFamily);
       
   171 
       
   172 // create subscribe parameter set object
       
   173 CSubConSIPSubscribeParamSet* sip = CSubConSIPSubscribeParamSet::NewL(*family,CSubConParameterFamily::ERequested);</codeblock> <p>Set <codeph>the
       
   174 required information that is, to</codeph>, <codeph>from</codeph>, <codeph>contact,</codeph> and <codeph>reqURI</codeph> header
       
   175 values to the SIP subscribe parameter set as explained in <xref href="GUID-4120651F-E0B9-5927-96B9-2662C51F5A09.dita#GUID-4120651F-E0B9-5927-96B9-2662C51F5A09/GUID-EE044B0B-4664-57DA-BAE1-F9A3B99C453C">Initiating a session using INVITE</xref> section. </p> <codeblock id="GUID-11671200-F24E-5278-9408-EE75399B25C2" xml:space="preserve">// Set the required information
       
   176 _LIT8(KEventType, "messagewaiting");    // subscription event type
       
   177 TPtrC8 ptrEventType (KEventType());
       
   178 sip-&gt;SetEventTypeL(ptrEventType);     //Set the subscription event type to 'messagewaiting'
       
   179 
       
   180 _LIT8(KAcceptType,  "application");    //accept type
       
   181 TPtrC8 ptrAcceptType(KAcceptType());
       
   182 sip-&gt;SetAcceptTypeL(ptrAcceptType); //set the accept type field to 'application'
       
   183 
       
   184 _LIT8(KAcceptSubType,   "indication"); //accept subtype
       
   185 TPtrC8 ptrAcceptSubType(KAcceptSubType());
       
   186 sip-&gt;SetAcceptSubTypeL(ptrAcceptSubType);    //set the accept subtype
       
   187 
       
   188 sip-&gt;SetExpires(3600);    // set the subscription Refresh timings
       
   189 
       
   190 sip-&gt;SetAutoRefresh(ETrue); // set Auto Refresh to 'on' 
       
   191 
       
   192 // pass SIP subscribe parameters through the subconnection
       
   193 Tint err = subCon.SetParameters(sipBundle);
       
   194 sipBundle.Close(); //close the parameter bundle
       
   195 
       
   196 subCon.Start();    // Start the subscription
       
   197 </codeblock> <p>To receive notifications to the subscribed events, <xref href="GUID-106A74C7-9B70-3397-973C-E317C1F40C58.dita"><apiname>CSubConSIPNotificationEvent</apiname></xref> class
       
   198 is used. </p> <codeblock id="GUID-4D3A9189-1AA5-5275-A5B6-425085006A25" xml:space="preserve">// Wait and receive notifications to events
       
   199 while(ETrue)
       
   200 {
       
   201 TNotificationEventBuf evtBuf;         // Sub-connection event notification object
       
   202 
       
   203     TRequestStatus reqStatus;             // request status object
       
   204 
       
   205     User::WaitForRequest(reqStatus);
       
   206     TInt eventId = evtBuf.Id();                     // get sub-type id
       
   207     TInt groupId = evtBuf.GroupId();         // get group id of the event
       
   208 
       
   209 if (eventId == KSubConSIPNotificationEventType &amp;&amp; groupId == KSubConSIPEventsUid)
       
   210         {
       
   211                 CSubConSIPNotificationEvent * evtRes = (CSubConSIPNotificationEvent*)CSubConNotificationEvent::NewL(evtBuf);
       
   212                 CleanupStack::PushL(evtRes);    
       
   213                 ....................
       
   214                 ....................
       
   215                 CleanupStack::PopAndDestroy(evtRes);    
       
   216 
       
   217             // Since We do not want to receive more notifications in this stage, break from the loop.
       
   218 
       
   219                 break;
       
   220         }
       
   221 
       
   222 // we can wait again for another notification
       
   223 subCon.EventNotification( evtBuf,EFalse, reqStatus);  //request for notification
       
   224 }</codeblock> <p>Unsubscribe to events and unregister, refer to steps in the <xref href="GUID-4120651F-E0B9-5927-96B9-2662C51F5A09.dita#GUID-4120651F-E0B9-5927-96B9-2662C51F5A09/GUID-FB267A38-FFB3-5360-9DC8-3E42C5C546A4">Terminating
       
   225 the session</xref> section. </p> <p><b>Setting authentication parameters</b> </p> <p>A
       
   226 remote party or a server may require authentication before it allows an endpoint
       
   227 to establish a session with another endpoint. <xref href="GUID-0AFDA357-EE44-3788-9CAB-162B874134BF.dita"><apiname>RSubConnection</apiname></xref> provides
       
   228 an authentication mechanism where the authentication information such as realm,
       
   229 username and password must be provided while initiating the call. If a challenge
       
   230 is received then <xref href="GUID-0AFDA357-EE44-3788-9CAB-162B874134BF.dita"><apiname>RSubConnection</apiname></xref> provides the realm and
       
   231 initiates a new session with authentication parameters. </p> <p>Authentication
       
   232 parameters are set in a subconnection parameter bundle as shown in the following
       
   233 code fragment. Set the SIP authenticate parameter set using <xref href="GUID-155DBCFD-76A4-3852-855E-0E0E8F1EC775.dita"><apiname>CSubConSIPAuthenticateParamSet</apiname></xref>.
       
   234 This class provides the SIP authenticate parameter values that are passed
       
   235 through the subconnection to the SIP stack. </p> <codeblock id="GUID-BE7DB575-79EE-5D13-B3CB-041579DD5D57" xml:space="preserve">RSubConParameterBundle     sipBundle;                         //    create parameter bundle
       
   236 // Add authorisation parameters as new family
       
   237 CSubConParameterFamily * family1 = CSubConParameterFamily::NewL(sipBundle,KSubConAuthorisationFamily );
       
   238 
       
   239 // create authenticate parameter set object
       
   240 CSubConSIPAuthenticateParamSet * authParam = CSubConSIPAuthenticateParamSet::NewL(*family1,CSubConParameterFamily::ERequested);
       
   241 </codeblock> <p>Set <codeph>the required information that is, to</codeph>, <codeph>from</codeph>, <codeph>contact</codeph>, <codeph>reqURI</codeph> header field values to the SIP authenticate parameter set, similar to that
       
   242 in <xref href="GUID-4120651F-E0B9-5927-96B9-2662C51F5A09.dita#GUID-4120651F-E0B9-5927-96B9-2662C51F5A09/GUID-EE044B0B-4664-57DA-BAE1-F9A3B99C453C">Initiating
       
   243 a session using INVITE</xref> section. </p> <codeblock id="GUID-55C1E9B8-B6CB-565D-9163-31421965C01A" xml:space="preserve">_LIT8(KRealm, "SFTF");
       
   244 _LIT8(KUserName, "MyUserName");
       
   245 _LIT8(KPwd, "pass123");
       
   246 
       
   247 authParam-&gt;SetRealmL(KRealm);    //set the Realm parameter
       
   248 authParam-&gt;SetUserNameL(KUserName);    // set the username
       
   249 authParam-&gt;SetPasswordL(KPwd);                    //set the password
       
   250 
       
   251 TInt err = subCon.SetParameters(sipBundle); //set the Authenticate parameters to the subconnection
       
   252 sipBundle.Close();                    //close the parameter bundle</codeblock> <p>To
       
   253 terminate the call session or unsubscribe to events and unregister, follow
       
   254 the steps in <xref href="GUID-4120651F-E0B9-5927-96B9-2662C51F5A09.dita#GUID-4120651F-E0B9-5927-96B9-2662C51F5A09/GUID-FB267A38-FFB3-5360-9DC8-3E42C5C546A4">Terminating
       
   255 the session</xref> section. </p> </section>
       
   256 <section id="GUID-FB267A38-FFB3-5360-9DC8-3E42C5C546A4"><title>Terminating
       
   257 the session</title> <p>To terminate the SIP INVITE or SUBSCRIBE session: </p> <ul>
       
   258 <li id="GUID-E1DABB93-F761-554F-82F9-78CAF0116A2C"><p>send BYE message by
       
   259 closing the <xref href="GUID-0AFDA357-EE44-3788-9CAB-162B874134BF.dita"><apiname>RSubConnection</apiname></xref> session </p> </li>
       
   260 <li id="GUID-D8757702-DB58-5F75-A00A-9251B3975CFF"><p>unregister with the
       
   261 SIP registrar by closing the <xref href="GUID-BED8A733-2ED7-31AD-A911-C1F4707C67FD.dita"><apiname>RConnection</apiname></xref> session. </p> </li>
       
   262 </ul> <codeblock id="GUID-F5281FE3-651C-5DAD-9569-5A7C967233F0" xml:space="preserve">Int ret = subCon.Stop();    // Terminate the session, send BYE message
       
   263 
       
   264 subCon.Close();        // close the subconnection
       
   265 
       
   266 con.Stop();      // Terminate the connection
       
   267 
       
   268 con.Close();        // Close the connection </codeblock> </section>
       
   269 <section id="GUID-B6F7F947-1E4B-4DFD-80B4-70E5E890685A"><title>See also</title> <p> <xref href="GUID-FA4F1E9F-8775-51E4-99DD-D334E73319C5.dita">Socket
       
   270 Server Protocols Overview</xref>  </p> <p> <xref href="GUID-6BB74A83-C6EA-5BC2-B60F-8186CC896725.dita">Sockets
       
   271 Client Overview</xref>  </p> <p><xref href="GUID-BD8446C5-3ADE-59A6-A13A-A5482D6FC56F.dita">Connection
       
   272 Management</xref></p> </section>
       
   273 </conbody></concept>