Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

[Index] [Glossary] [Previous] [Next]



How 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, the class RCounter, derived from RSubSessionBase, represents the client side subsession with a server, called the count server in this example. The assumption is made that the client has already established a session with the server as represented by the RCountServ class.

class RCounter : public RSubSessionBase
 {
public:
 TInt Open(RCountServ &aServer);
 void SetFromString(TDesC& aString);
 void Close();
 void Increase();
 void Decrease();
 void IncreaseBy(TInt anInt);
 void DecreaseBy(TInt anInt);
 void Reset();
 TInt CounterValue();
 };

class RCountServ : public RSessionBase
 {
public:
 RCountServ();
 TInt Connect();
 ...
 TVersion Version() const;
 void Close();
 };

The important points in this example are:

TInt RCounter::CounterValue()
 {
 TInt res=0;
 TPckgBuf<TInt> pckg;
 if (SubSessionHandle())
  {
  TAny *p[KMaxMessageArguments];
  p[0]=(TAny *) &pckg;
  SendReceive(ECountServValue,&p[0]);
  res = pckg();
  }
 return res;

}


Notes