8 Contributors: |
8 Contributors: |
9 --> |
9 --> |
10 <!DOCTYPE concept |
10 <!DOCTYPE concept |
11 PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd"> |
11 PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd"> |
12 <concept id="GUID-D043376C-29D2-5196-96F4-15E99CFB5639" xml:lang="en"><title> RSubConnection |
12 <concept id="GUID-D043376C-29D2-5196-96F4-15E99CFB5639" xml:lang="en"><title> RSubConnection |
13 API Tutorial</title><shortdesc>How to use an <apiname>RSubConnection</apiname>. </shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody> |
13 API Tutorial</title><shortdesc>How to use an <codeph>RSubConnection</codeph>. </shortdesc><prolog><metadata><keywords/></metadata></prolog><conbody> |
14 <section id="GUID-254081A7-16C0-45C5-B964-4B47D6EB4590"><title>Procedure</title> <ol id="GUID-C81387B5-9ED3-59ED-A5DC-C6FE807B2E1C"> |
14 <section id="GUID-254081A7-16C0-45C5-B964-4B47D6EB4590"><title>Procedure</title> <ol id="GUID-C81387B5-9ED3-59ED-A5DC-C6FE807B2E1C"> |
15 <li id="GUID-46077726-D57D-5A89-A022-D1EDD45FFE3C"><p>Use the <codeph>Open()</codeph> method |
15 <li id="GUID-46077726-D57D-5A89-A022-D1EDD45FFE3C"><p>Use the <codeph>Open()</codeph> method |
16 to open an <xref href="GUID-0AFDA357-EE44-3788-9CAB-162B874134BF.dita"><apiname>RSubConnection</apiname></xref> object on an ESOCK session. </p> <p>The <xref href="GUID-BED8A733-2ED7-31AD-A911-C1F4707C67FD.dita"><apiname>RConnection</apiname></xref> must |
16 to open an <xref href="GUID-0AFDA357-EE44-3788-9CAB-162B874134BF.dita"><apiname>RSubConnection</apiname></xref> object on an ESOCK session. </p> <p>The <xref href="GUID-BED8A733-2ED7-31AD-A911-C1F4707C67FD.dita"><apiname>RConnection</apiname></xref> must |
17 already be active. A sub-connection type is passed as a parameter to this |
17 already be active. A sub-connection type is passed as a parameter to this |
18 method. It is then attached to the default sub-connection that is the <xref href="GUID-BED8A733-2ED7-31AD-A911-C1F4707C67FD.dita"><apiname>RConnection</apiname></xref>, |
18 method. It is then attached to the default sub-connection that is the <xref href="GUID-BED8A733-2ED7-31AD-A911-C1F4707C67FD.dita"><apiname>RConnection</apiname></xref>, |
76 destAddr.SetPort(KEchoPort); |
76 destAddr.SetPort(KEchoPort); |
77 |
77 |
78 // Request the Socket to connect to the destination over the default sub-connection |
78 // Request the Socket to connect to the destination over the default sub-connection |
79 sock.Connect(destAddr, status); |
79 sock.Connect(destAddr, status); |
80 </codeblock> </example> |
80 </codeblock> </example> |
81 <section id="GUID-D707232A-A1B5-4F8F-98D4-D6EBC253DF94"><title>Creating a sub-connection - Socket connected over the |
81 <section id="GUID-D707232A-A1B5-4F8F-98D4-D6EBC253DF94"><title>Creating a |
82 SubConnection example</title> <p>The following example shows how an |
82 sub-connection - Socket connected over the SubConnection example</title> <p>The |
83 application can use a sub-connection through an <xref href="GUID-0AFDA357-EE44-3788-9CAB-162B874134BF.dita"><apiname>RSubConnection</apiname></xref> instance. |
83 following example shows how an application can use a sub-connection through |
84 It attaches an <codeph>RSocket</codeph> to the sub-connection. </p> <codeblock id="GUID-F7E8A10E-4A1C-5547-A2F5-783D0A914EA3" xml:space="preserve">RSocketServ ss; |
84 an <xref href="GUID-0AFDA357-EE44-3788-9CAB-162B874134BF.dita"><apiname>RSubConnection</apiname></xref> instance. It attaches an <codeph>RSocket</codeph> to |
|
85 the sub-connection. </p> <codeblock id="GUID-F7E8A10E-4A1C-5547-A2F5-783D0A914EA3" xml:space="preserve">RSocketServ ss; |
85 RConnection conn; |
86 RConnection conn; |
86 RSubConnection subconn; |
87 RSubConnection subconn; |
87 RSocket sock; |
88 RSocket sock; |
88 TRequestStatus status; |
89 TRequestStatus status; |
89 |
90 |
114 destAddr.SetPort(KEchoPort); |
115 destAddr.SetPort(KEchoPort); |
115 |
116 |
116 // Request the Socket to connect to the destination over the sub-connection |
117 // Request the Socket to connect to the destination over the sub-connection |
117 sock.Connect(destAddr, status); |
118 sock.Connect(destAddr, status); |
118 </codeblock> </section> |
119 </codeblock> </section> |
119 <section id="GUID-0766B25A-8073-47E7-A86E-4D172D050064"><title>Creating a new sub-connection - Adding an already connected |
120 <section id="GUID-0766B25A-8073-47E7-A86E-4D172D050064"><title>Creating a |
120 socket example</title> <p>The following example shows how an application |
121 new sub-connection - Adding an already connected socket example</title> <p>The |
121 can use a sub-connection through an <xref href="GUID-0AFDA357-EE44-3788-9CAB-162B874134BF.dita"><apiname>RSubConnection</apiname></xref> instance. |
122 following example shows how an application can use a sub-connection through |
122 It attaches a connected <codeph>RSocket</codeph> to the sub-connection. </p> <codeblock id="GUID-27ACF33C-004D-5538-AF34-175F66D73C6B" xml:space="preserve">RSocketServ ss; |
123 an <xref href="GUID-0AFDA357-EE44-3788-9CAB-162B874134BF.dita"><apiname>RSubConnection</apiname></xref> instance. It attaches a connected <codeph>RSocket</codeph> to |
|
124 the sub-connection. </p> <codeblock id="GUID-27ACF33C-004D-5538-AF34-175F66D73C6B" xml:space="preserve">RSocketServ ss; |
123 RConnection conn; |
125 RConnection conn; |
124 RSubConnection subconn; |
126 RSubConnection subconn; |
125 RSocket sock; |
127 RSocket sock; |
126 TRequestStatus status; |
128 TRequestStatus status; |
127 |
129 |
159 subconn.Add(sock, status); |
161 subconn.Add(sock, status); |
160 |
162 |
161 // Wait for socket to added |
163 // Wait for socket to added |
162 User::WaitForRequest(status); |
164 User::WaitForRequest(status); |
163 </codeblock> </section> |
165 </codeblock> </section> |
164 <section id="GUID-BC00A713-123E-401D-9E99-BE52C920D71B"><title>Creating and setting properties for a SubConnection |
166 <section id="GUID-BC00A713-123E-401D-9E99-BE52C920D71B"><title>Creating and |
165 example</title> <p>The following example shows how an application creates |
167 setting properties for a SubConnection example</title> <p>The following |
166 and sets the QoS properties. It assigns the properties to a sub-connection. </p> <codeblock id="GUID-6A478B1D-3A6E-5FB1-BD5E-2485A86539C1" xml:space="preserve">// Create the container for all sub connection parameters |
168 example shows how an application creates and sets the QoS properties. It assigns |
|
169 the properties to a sub-connection. </p> <codeblock id="GUID-6A478B1D-3A6E-5FB1-BD5E-2485A86539C1" xml:space="preserve">// Create the container for all sub connection parameters |
167 RSubConParameterBundle subconParams; |
170 RSubConParameterBundle subconParams; |
168 CleanupClosePushL(subconParams); |
171 CleanupClosePushL(subconParams); |
169 |
172 |
170 // Create a container for QoS sub connection parameters (Param bundle takes ownership) |
173 // Create a container for QoS sub connection parameters (Param bundle takes ownership) |
171 CSubConParameterFamily* qosFamily = CSubConParameterFamily::NewL(subconParams, |
174 CSubConParameterFamily* qosFamily = CSubConParameterFamily::NewL(subconParams, |
229 |
232 |
230 // Fetch the granted qos |
233 // Fetch the granted qos |
231 RSubConParameterBundle grantedParams; |
234 RSubConParameterBundle grantedParams; |
232 subconn.GetParameters(grantedParams); |
235 subconn.GetParameters(grantedParams); |
233 </codeblock> </section> |
236 </codeblock> </section> |
234 <section id="GUID-781F3343-94E7-4BF5-8840-0CDFFB0B99B2"><title>Registering for events example</title> <p>The following example |
237 <section id="GUID-781F3343-94E7-4BF5-8840-0CDFFB0B99B2"><title>Registering |
235 shows how an application can register events that occur on a sub-connection. |
238 for events example</title> <p>The following example shows how an application |
236 In this example the application registers for notification of all events. </p> <codeblock id="GUID-B6B202DB-323A-528F-B6F6-60160A140EA5" xml:space="preserve">// Create the container for all sub connection parameters |
239 can register events that occur on a sub-connection. In this example the application |
|
240 registers for notification of all events. </p> <codeblock id="GUID-B6B202DB-323A-528F-B6F6-60160A140EA5" xml:space="preserve">// Create the container for all sub connection parameters |
237 RSubConParameterBundle subconParams; |
241 RSubConParameterBundle subconParams; |
238 CleanupClosePushL(subconParams); |
242 CleanupClosePushL(subconParams); |
239 |
243 |
240 ……… |
244 ……… |
241 ……… |
245 ……… |
307 User::WaitForRequest(status); |
311 User::WaitForRequest(status); |
308 |
312 |
309 // Event should be CSubconGenEventParamsGranted/CSubconGenEventParamsRejected |
313 // Event should be CSubconGenEventParamsGranted/CSubconGenEventParamsRejected |
310 User::WaitForRequest(eventStatus); |
314 User::WaitForRequest(eventStatus); |
311 </codeblock> </section> |
315 </codeblock> </section> |
312 <section id="GUID-6FDFB388-B265-4A7B-9752-AC75DF6C3995"><title>Extracting information from received events example</title> <p>The |
316 <section id="GUID-6FDFB388-B265-4A7B-9752-AC75DF6C3995"><title>Extracting |
313 following example code shows how to extract the information contained within |
317 information from received events example</title> <p>The following example |
314 an event notification when it is received. </p> <codeblock id="GUID-BCCE128C-0042-5E36-B22C-35A22A6DFE85" xml:space="preserve">// Create the container for all sub connection parameters |
318 code shows how to extract the information contained within an event notification |
|
319 when it is received. </p> <codeblock id="GUID-BCCE128C-0042-5E36-B22C-35A22A6DFE85" xml:space="preserve">// Create the container for all sub connection parameters |
315 RSubConParameterBundle subconParams; |
320 RSubConParameterBundle subconParams; |
316 CleanupClosePushL(subconParams); |
321 CleanupClosePushL(subconParams); |
317 |
322 |
318 ……… |
323 ……… |
319 ……… |
324 ……… |