diff -r 4816d766a08a -r f345bda72bc4 Symbian3/PDK/Source/GUID-579D7C32-B6C8-5C77-88A5-B3078729E1BA.dita --- a/Symbian3/PDK/Source/GUID-579D7C32-B6C8-5C77-88A5-B3078729E1BA.dita Tue Mar 30 11:42:04 2010 +0100 +++ b/Symbian3/PDK/Source/GUID-579D7C32-B6C8-5C77-88A5-B3078729E1BA.dita Tue Mar 30 11:56:28 2010 +0100 @@ -1,65 +1,65 @@ - - - - - -How -to implement a simple client interfaceProvides code snippets to help you to implement a simple client -interface. -
Client side session with a server

A client side -session is represented by an instance of a class derived from RSessionBase which -provides the behaviour for connecting to the server and sending messages to -it.

In the following code fragment, taken from the example that can -be found at ...\examples\Base\IPC\ClientServer\simple, -the class RCountServSession, derived from RSessionBase, -represents the client side session with a server. In the example, this may -be referred to as the "count server". Note that sessions can not be shared -in this example, and it just shows the basic mechanics of the client/server -interaction.

class RCountServSession : public RSessionBase - { -public: - RCountServSession(); - TInt Connect(); - TVersion Version() const; - TInt UnsupportedRequest(); - TInt SetFromString(const TDesC& aString); - void Increase(); - void Decrease(); - void IncreaseBy(TInt anInt); - void DecreaseBy(TInt anInt); - void Reset(); - TInt CounterValue(); - void BadRequest(); - void Close(); -private: - RThread iServerThread; - };

The important points are:

    -
  • Use Connect() to -start the count server. This calls RSessionBase::CreateSession() to -create a session with the server. Note that in this simple example, the server -is implemented as a separate thread, which is started by the example executable.

  • -
  • Use a client interface -function, such as Increase(), to send a specific message -to the server. The client interface function builds the message using the -appropriate operation code and assembling a suitable TIpcArgs object, -i.e. the object containing the integers and/or the descriptor pointers to -the message arguments in the client address space.

  • -

As an example, the function SetFromString() is implemented -as follows:

TInt RCountServSession::SetFromString(const TDesC& aString) - { - TIpcArgs args(&aString); - return SendReceive(ECountServSetFromString, args); - }

SendReceive() is called, specifying -an operation code ECountServSetFromString and a TIpcArgs object -containing argument values. In this case, there is only one argument - a pointer -to a TDesC object containing the string to be passed to the -server. Typically, operation codes are enum values defined in a header file -visible to both the client interface and the server. Note that the client -descriptor must remain in existence until the server request completes.

+ + + + + +How +to implement a simple client interfaceProvides code snippets to help you to implement a simple client +interface. +
Client side session with a server

A client side +session is represented by an instance of a class derived from RSessionBase which +provides the behaviour for connecting to the server and sending messages to +it.

In the following code fragment, taken from the example that can +be found at ...\examples\Base\IPC\ClientServer\simple, +the class RCountServSession, derived from RSessionBase, +represents the client side session with a server. In the example, this may +be referred to as the "count server". Note that sessions can not be shared +in this example, and it just shows the basic mechanics of the client/server +interaction.

class RCountServSession : public RSessionBase + { +public: + RCountServSession(); + TInt Connect(); + TVersion Version() const; + TInt UnsupportedRequest(); + TInt SetFromString(const TDesC& aString); + void Increase(); + void Decrease(); + void IncreaseBy(TInt anInt); + void DecreaseBy(TInt anInt); + void Reset(); + TInt CounterValue(); + void BadRequest(); + void Close(); +private: + RThread iServerThread; + };

The important points are:

    +
  • Use Connect() to +start the count server. This calls RSessionBase::CreateSession() to +create a session with the server. Note that in this simple example, the server +is implemented as a separate thread, which is started by the example executable.

  • +
  • Use a client interface +function, such as Increase(), to send a specific message +to the server. The client interface function builds the message using the +appropriate operation code and assembling a suitable TIpcArgs object, +i.e. the object containing the integers and/or the descriptor pointers to +the message arguments in the client address space.

  • +

As an example, the function SetFromString() is implemented +as follows:

TInt RCountServSession::SetFromString(const TDesC& aString) + { + TIpcArgs args(&aString); + return SendReceive(ECountServSetFromString, args); + }

SendReceive() is called, specifying +an operation code ECountServSetFromString and a TIpcArgs object +containing argument values. In this case, there is only one argument - a pointer +to a TDesC object containing the string to be passed to the +server. Typically, operation codes are enum values defined in a header file +visible to both the client interface and the server. Note that the client +descriptor must remain in existence until the server request completes.

\ No newline at end of file