diff -r ebc84c812384 -r 46218c8b8afa Symbian3/PDK/Source/GUID-4C7ABD1C-B42C-590A-AD24-7FA6C3A8D18C.dita --- a/Symbian3/PDK/Source/GUID-4C7ABD1C-B42C-590A-AD24-7FA6C3A8D18C.dita Thu Mar 11 15:24:26 2010 +0000 +++ b/Symbian3/PDK/Source/GUID-4C7ABD1C-B42C-590A-AD24-7FA6C3A8D18C.dita Thu Mar 11 18:02:22 2010 +0000 @@ -1,124 +1,124 @@ - - - - - - Registering for Sub-Connection events: Tutorial

This tutorial describes how an application can register for sub-connection events.

This tutorial has three parts. The first part describes how the application can register for all events. The second part describes how the application can register for a subset of events. The third part describes how the application can extract information from an event response.

Registering for events – Simple case

The following example shows the simplest case of how an application can register for events occurring on a sub-connection. In this example the application registers for notification of all events.

// Create the container for all sub connection parameters -RSubConParameterBundle subconParams; -CleanupClosePushL(subconParams); - -……… -……… -// Create and initialise parameters sets as above -……… -……… - -// Create a new sub-connection -subconn.Open(ss, RSubConnection::ECreateNew, conn); - -TNotificationEventBuf eventBuffer; -TRequestStatus eventStatus; -subconn.EventNotification(eventBuffer, EFalse, eventStatus); - -// Set Properties of the sub-connection -subconn.SetParameters(subconParams); - -// Destroy parameters -CleanupStack::PopAndDestroy(); // subconParams - -// Open and connect a TCP socket on the sub-connection -sock.Open(ss, KAfInet, KSockStream, KProtocolInetTcp, subconn); -sock.Connect(destAddr, status); -User::WaitForRequest(status); - -// Negotiation may not occur until a socket is assigned to the sub-connection -// First event should be cSubConGenEventDataClientJoining -User::WaitForRequest(eventStatus); - -// Next we’d expect a CSubconGenEventParamsGranted/ CSubconGenEventParamsRejected -subconn.EventNotification(eventBuffer, EFalse, eventStatus); -User::WaitForRequest(eventStatus); -

Note: Error handling is not included to aid clarity.

Registering for events – Using filters

The following example shows how to register for specific events by using filters. In this example the application registers for notification when sub-connection parameters have been granted or rejected. Each TEventFilter contains the factory Uid of the events and a mask of event Ids bitwise OR’d together.

// Create the container for all sub connection parameters -RSubConParameterBundle subconParams; -CleanupClosePushL(subconParams); - -……… -……… -// Create and initialise parameters sets as above -……… -……… - -// Create a new sub-connection -subconn.Open(ss, RSubConnection::ECreateNew, conn); - -// Create event filter -TEventFilter filter; -filter.iEventGroupUid = KSubConnGenericEventsImplUid; -filter.iEventMask = KSubConGenericEventParamsRejected | KSubConGenericEventParamsGranted; - -// Register for event -TNotificationEventBuf eventBuffer; -TRequestStatus eventStatus; -subconn.EventNotification(eventBuffer, &filter, 1, eventStatus); - -// Set Properties of the sub-connection -subconn.SetParameters(subconParams); - -// Destroy parameters -CleanupStack::PopAndDestroy(); // subconParams - -// Open and connect a TCP socket on the sub-connection -sock.Open(ss, KAfInet, KSockStream, KProtocolInetTcp, subconn); -sock.Connect(destAddr, status); -User::WaitForRequest(status); - -// Event should be CSubconGenEventParamsGranted/CSubconGenEventParamsRejected -User::WaitForRequest(eventStatus); -

Note: Error handling is not included to aid clarity.

Extracting information from received events

The following example shows how to extract the information contained within an event notification once it has been received.

// Create the container for all sub connection parameters -RSubConParameterBundle subconParams; -CleanupClosePushL(subconParams); - -……… -……… -// Create and initialise parameters sets as above -……… -……… - -// Create a new sub-connection -subconn.Open(ss, RSubConnection::ECreateNew, conn); - -// Create filter, register for events, and set parameters as above -…… -subconn.EventNotification(eventBuffer, &filter, 1, eventStatus); -…… - -// Open and connect a TCP socket on the sub-connection -…… - -// Receive the event notification -User::WaitForRequest(eventStatus); - -CSubConNotificationEvent* event; -event = CSubConNotificationEvent::NewL(eventBuffer); -CleanupStack::PushL (event); - -if (event->GroupId() == KSubConnGenericEventsImplUid - && event->Id() == CSubConGenEventParamsRejected) - { - CSubConGenEventParamsRejected* rejectedEvent = - static_cast< CSubConGenEventParamsRejected*>(event); - - TInt error = rejectedEvent->Error(); - …… - // Do something with the error - …… - } - -CleanupStack::PopAndDestroy (event); + + + + + + Registering for Sub-Connection events: Tutorial

This tutorial describes how an application can register for sub-connection events.

This tutorial has three parts. The first part describes how the application can register for all events. The second part describes how the application can register for a subset of events. The third part describes how the application can extract information from an event response.

Registering for events – Simple case

The following example shows the simplest case of how an application can register for events occurring on a sub-connection. In this example the application registers for notification of all events.

// Create the container for all sub connection parameters +RSubConParameterBundle subconParams; +CleanupClosePushL(subconParams); + +……… +……… +// Create and initialise parameters sets as above +……… +……… + +// Create a new sub-connection +subconn.Open(ss, RSubConnection::ECreateNew, conn); + +TNotificationEventBuf eventBuffer; +TRequestStatus eventStatus; +subconn.EventNotification(eventBuffer, EFalse, eventStatus); + +// Set Properties of the sub-connection +subconn.SetParameters(subconParams); + +// Destroy parameters +CleanupStack::PopAndDestroy(); // subconParams + +// Open and connect a TCP socket on the sub-connection +sock.Open(ss, KAfInet, KSockStream, KProtocolInetTcp, subconn); +sock.Connect(destAddr, status); +User::WaitForRequest(status); + +// Negotiation may not occur until a socket is assigned to the sub-connection +// First event should be cSubConGenEventDataClientJoining +User::WaitForRequest(eventStatus); + +// Next we’d expect a CSubconGenEventParamsGranted/ CSubconGenEventParamsRejected +subconn.EventNotification(eventBuffer, EFalse, eventStatus); +User::WaitForRequest(eventStatus); +

Note: Error handling is not included to aid clarity.

Registering for events – Using filters

The following example shows how to register for specific events by using filters. In this example the application registers for notification when sub-connection parameters have been granted or rejected. Each TEventFilter contains the factory Uid of the events and a mask of event Ids bitwise OR’d together.

// Create the container for all sub connection parameters +RSubConParameterBundle subconParams; +CleanupClosePushL(subconParams); + +……… +……… +// Create and initialise parameters sets as above +……… +……… + +// Create a new sub-connection +subconn.Open(ss, RSubConnection::ECreateNew, conn); + +// Create event filter +TEventFilter filter; +filter.iEventGroupUid = KSubConnGenericEventsImplUid; +filter.iEventMask = KSubConGenericEventParamsRejected | KSubConGenericEventParamsGranted; + +// Register for event +TNotificationEventBuf eventBuffer; +TRequestStatus eventStatus; +subconn.EventNotification(eventBuffer, &filter, 1, eventStatus); + +// Set Properties of the sub-connection +subconn.SetParameters(subconParams); + +// Destroy parameters +CleanupStack::PopAndDestroy(); // subconParams + +// Open and connect a TCP socket on the sub-connection +sock.Open(ss, KAfInet, KSockStream, KProtocolInetTcp, subconn); +sock.Connect(destAddr, status); +User::WaitForRequest(status); + +// Event should be CSubconGenEventParamsGranted/CSubconGenEventParamsRejected +User::WaitForRequest(eventStatus); +

Note: Error handling is not included to aid clarity.

Extracting information from received events

The following example shows how to extract the information contained within an event notification once it has been received.

// Create the container for all sub connection parameters +RSubConParameterBundle subconParams; +CleanupClosePushL(subconParams); + +……… +……… +// Create and initialise parameters sets as above +……… +……… + +// Create a new sub-connection +subconn.Open(ss, RSubConnection::ECreateNew, conn); + +// Create filter, register for events, and set parameters as above +…… +subconn.EventNotification(eventBuffer, &filter, 1, eventStatus); +…… + +// Open and connect a TCP socket on the sub-connection +…… + +// Receive the event notification +User::WaitForRequest(eventStatus); + +CSubConNotificationEvent* event; +event = CSubConNotificationEvent::NewL(eventBuffer); +CleanupStack::PushL (event); + +if (event->GroupId() == KSubConnGenericEventsImplUid + && event->Id() == CSubConGenEventParamsRejected) + { + CSubConGenEventParamsRejected* rejectedEvent = + static_cast< CSubConGenEventParamsRejected*>(event); + + TInt error = rejectedEvent->Error(); + …… + // Do something with the error + …… + } + +CleanupStack::PopAndDestroy (event);

Note: Error handling is not included to aid clarity.

\ No newline at end of file