diff -r 4816d766a08a -r f345bda72bc4 Symbian3/PDK/Source/GUID-A30C1204-F130-501E-BD2D-1EE1537BEFC3.dita --- a/Symbian3/PDK/Source/GUID-A30C1204-F130-501E-BD2D-1EE1537BEFC3.dita Tue Mar 30 11:42:04 2010 +0100 +++ b/Symbian3/PDK/Source/GUID-A30C1204-F130-501E-BD2D-1EE1537BEFC3.dita Tue Mar 30 11:56:28 2010 +0100 @@ -1,99 +1,99 @@ - - - - - -How -to implement a client interface with subsessionsProvides code snippets to help you to implement a -client interface with subsessions. -

A client side subsession is represented by an instance of a class derived -from RSubSessionBase which provides the behaviour for:

- -

In the following code fragment, taken from the example that can be found -at ...\examples\Base\IPC\ClientServer\complex, the class RCountSubSession, -derived from RSubSessionBase, represents the client side -subsession with a server (in the example the server is also referred to as -the count server). The assumption is made that the client has already established -a session with the server as represented by the RCountSession class.

-class RCountSubSession : public RSubSessionBase - { -public: - TInt Open(RCountSession& aServer); - TInt SetFromString(const TDesC& aString); - void Close(); - void Increase(); - void Decrease(); - void IncreaseBy(TInt anInt); - void DecreaseBy(TInt anInt); - void Reset(); - TInt CounterValue(); - }; - -class RCountSession : public RSessionBase - { -public: - RCountSession(); - TInt Connect(); - TVersion Version() const; - TInt ResourceCount(); - void Close(); -private: - RThread iServerThread; - }; -

The important points in this example are:

- - -
Notes
    -
  • The operation code passed -to RSubSessionBase::CreateSubSession() must be interpreted -by the server as a request to create a subsession.

  • -
  • When sending a message -to the server with a call to RSubSessionBase::SendReceive(), -only three arguments can be passed . This function always uses the fourth -argument to hold the client subsession handle number which is used to identify -the corresponding server side subsession object. The message arguments are -subsequently passed to a call to RSessionBase::SendReceive().

  • -
  • The operation code passed -to RSubSessionBase::CloseSubSession() must be interpreted -by the server as a request to close the subsession.

  • -
+ + + + + +How +to implement a client interface with subsessionsProvides code snippets to help you to implement a +client interface with subsessions. +

A client side subsession is represented by an instance of a class derived +from RSubSessionBase which provides the behaviour for:

+
    +
  • creating a subsession +in the server

  • +
  • sending messages to +the subsession.

  • +
+

In the following code fragment, taken from the example that can be found +at ...\examples\Base\IPC\ClientServer\complex, the class RCountSubSession, +derived from RSubSessionBase, represents the client side +subsession with a server (in the example the server is also referred to as +the count server). The assumption is made that the client has already established +a session with the server as represented by the RCountSession class.

+class RCountSubSession : public RSubSessionBase + { +public: + TInt Open(RCountSession& aServer); + TInt SetFromString(const TDesC& aString); + void Close(); + void Increase(); + void Decrease(); + void IncreaseBy(TInt anInt); + void DecreaseBy(TInt anInt); + void Reset(); + TInt CounterValue(); + }; + +class RCountSession : public RSessionBase + { +public: + RCountSession(); + TInt Connect(); + TVersion Version() const; + TInt ResourceCount(); + void Close(); +private: + RThread iServerThread; + }; +

The important points in this example are:

+
    +
  • Open() creates +a subsession within the client-side session. A reference to the client-side +session is specified as the function's single argument. The function calls RSubSessionBase::CreateSubSession() which, +in turn, causes a server side subsession object to be created and its handle +number to be returned.

  • +
  • Client subsession interface +functions, such as CounterValue(), send a specific message +to the server.

    TInt RCountSubSession::CounterValue() + { + TInt res = KErrNotFound; + TPckgBuf<TInt> pckg; + + if (SubSessionHandle()) + { + // Note that TPckgBuf is of type TDes8 + TIpcArgs args(&pckg); + SendReceive(ECountServValue, args); + + // Extract the value returned from the server. + res = pckg(); + } + + return res; + }
  • +
+
    +
  • Close() closes +the subsession.

  • +
+
Notes
    +
  • The operation code passed +to RSubSessionBase::CreateSubSession() must be interpreted +by the server as a request to create a subsession.

  • +
  • When sending a message +to the server with a call to RSubSessionBase::SendReceive(), +only three arguments can be passed . This function always uses the fourth +argument to hold the client subsession handle number which is used to identify +the corresponding server side subsession object. The message arguments are +subsequently passed to a call to RSessionBase::SendReceive().

  • +
  • The operation code passed +to RSubSessionBase::CloseSubSession() must be interpreted +by the server as a request to close the subsession.

  • +
\ No newline at end of file