CServer2 Class Reference

class CServer2 : public CActive

Abstract base class for servers (version 2).

This is an active object. It accepts requests from client threads and forwards them to the relevant server-side client session. It also handles the creation of server-side client sessions as a result of requests from client threads.

A server must define and implement a derived class.

(Note that this class should be used instead of CServer)

Inherits from

Public Member Functions
~CServer2 ()
IMPORT_C void ReStart ()
RServer2 Server ()
IMPORT_C void SetMaster (const CServer2 *)
IMPORT_C void SetPinClientDescriptors ( TBool )
IMPORT_C TInt Start (const TDesC &)
IMPORT_C void StartL (const TDesC &)
Protected Member Functions
CServer2 ( TInt , TServerType )
IMPORT_C void DoCancel ()
IMPORT_C void DoConnect (const RMessage2 &)
IMPORT_C TInt Extension_ ( TUint , TAny *&, TAny *)
const RMessage2 & Message ()
IMPORT_C TInt RunError ( TInt )
IMPORT_C void RunL ()
Private Member Functions
void BadMessage (const RMessage2 &)
void Connect (const RMessage2 &)
void Disconnect (const RMessage2 &)
void DoConnectL (const RMessage2 &, CSession2 *volatile &)
IMPORT_C CSession2 * NewSessionL (const TVersion &, const RMessage2 &)
void NotConnected (const RMessage2 &)
Inherited Functions
CActive::CActive(TInt)
CActive::Cancel()
CActive::Deque()
CActive::IsActive()const
CActive::IsAdded()const
CActive::Priority()const
CActive::SetActive()
CActive::SetPriority(TInt)
CActive::~CActive()
CBase::CBase()
CBase::Delete(CBase *)
CBase::operator new(TUint)
CBase::operator new(TUint,TAny *)
CBase::operator new(TUint,TLeave)
CBase::operator new(TUint,TLeave,TUint)
CBase::operator new(TUint,TUint)
CBase::~CBase()
Public Member Enumerations
enum TPanic { EBadMessageNumber , ESessionNotConnected , ESessionAlreadyConnected , EClientDoesntHaveRequiredCaps }
enum TServerType { EUnsharableSessions  = EIpcSession_Unsharable, ESharableSessions  = EIpcSession_Sharable, EGlobalSharableSessions  = EIpcSession_GlobalSharable }
Inherited Enumerations
CActive:TPriority
Protected Attributes
TDblQueIter < CSession2 > iSessionIter
Private Attributes
RMessage2 iMessage
RServer2 iServer
TUint16 iServerOpts
TUint8 iServerRole
TDblQue < CSession2 > iSessionQ
TUint8 iSessionType
TAny * iSpare
Inherited Attributes
CActive::iStatus

Constructor & Destructor Documentation

CServer2(TInt, TServerType)

IMPORT_C CServer2 ( TInt aPriority,
TServerType aType = EUnsharableSessions
) [protected]

Constructs the server object, specifying the server type and the active object priority.

Derived classes must define and implement a constructor through which the priority can be specified. A typical implementation calls this server base class constructor through a constructor initialization list.

Parameters

TInt aPriority The priority of this active object.
TServerType aType = EUnsharableSessions Indicates the type of session that the server creates. If not explicitly stated, then the server creates a session that is not sharable with other threads.

~CServer2()

IMPORT_C ~CServer2 ( ) [pure virtual]

Frees resources prior to destruction.

Specifically, it cancels any outstanding request for messages, and deletes all server-side client session objects.

Member Functions Documentation

BadMessage(const RMessage2 &)

void BadMessage ( const RMessage2 & aMessage ) [private, static]

Parameters

const RMessage2 & aMessage

Connect(const RMessage2 &)

void Connect ( const RMessage2 & aMessage ) [private]

Parameters

const RMessage2 & aMessage

Disconnect(const RMessage2 &)

void Disconnect ( const RMessage2 & aMessage ) [private]

Parameters

const RMessage2 & aMessage

DoCancel()

IMPORT_C void DoCancel ( ) [protected, virtual]

Implements the cancellation of any outstanding request for messages.

DoConnect(const RMessage2 &)

IMPORT_C void DoConnect ( const RMessage2 & aMessage ) [protected, virtual]

Handles the connect request from the client. We trap Leaves, to ensure that existing sessions aren't affected by failure to create a new one.

Parameters

const RMessage2 & aMessage The Connect message sent by the client requesting the connection. aMessage.Ptr0() is the required Version.

DoConnectL(const RMessage2 &, CSession2 *volatile &)

void DoConnectL ( const RMessage2 & aMessage,
CSession2 *volatile & aSession
) [private]

Parameters

const RMessage2 & aMessage
CSession2 *volatile & aSession

Extension_(TUint, TAny *&, TAny *)

IMPORT_C TInt Extension_ ( TUint aExtensionId,
TAny *& a0,
TAny * a1
) [protected, virtual]

Extension function

Parameters

TUint aExtensionId
TAny *& a0
TAny * a1

Message()

const RMessage2 & Message ( ) const [protected, inline]

Gets a reference to the server's current message.

NewSessionL(const TVersion &, const RMessage2 &)

IMPORT_C CSession2 * NewSessionL ( const TVersion & aVersion,
const RMessage2 & aMessage
) const [private, pure virtual]

Creates a server-side session object.

The session represents a communication link between a client and a server, and its creation is initiated by the client through a call to one of the RSessionBase::CreateSession() variants.

A server must provide an implementation, which as a minimum should:

  • check that the version of the server is compatible with the client by comparing the client supplied version number against the server's version number; it should leave if there is incompatibility.

  • construct and return the server side client session object.

User::QueryVersionSupported()

Parameters

const TVersion & aVersion The version information supplied by the client.
const RMessage2 & aMessage Represents the details of the client request that is requesting the creation of the session.

NotConnected(const RMessage2 &)

void NotConnected ( const RMessage2 & aMessage ) [private, static]

Parameters

const RMessage2 & aMessage

ReStart()

IMPORT_C void ReStart ( )

Restarts the server.

The function issues a request for messages.

RunError(TInt)

IMPORT_C TInt RunError ( TInt aError ) [protected, virtual]

Handles the situation where a call to CServer2::RunL() , leaves.

This is the server active object's implementation of the active object framework's RunError() function.

In practice, the leave can only be caused by a session's ServiceL() function, which is called from this RunL() ; this error is reflected back to that session by calling its ServiceError() function.

CActive::RunL() CActive::RunError() CSession2::ServiceError()

Parameters

TInt aError The leave code.

RunL()

IMPORT_C void RunL ( ) [protected, virtual]

Handles the receipt of a message.

Server()

RServer2 Server ( ) const [inline]

Gets a handle to the server.

Note that the RServer2 object is classified as Symbian internal, and its member functions cannot be acessed. However, the handle can be passed to the RSessionBase::CreateSession() variants that take a server handle.

SetMaster(const CServer2 *)

IMPORT_C void SetMaster ( const CServer2 * aServer )

Assigns a role (master or slave) for this server.

The master server is typically named, and receives all Connect messages from clients. It can hand off some sessions to be processed by one or more anonymous slave servers, each running in a separate thread.

Both master and slave servers must call this function before calling Start() , in order to define their roles. Once the server is started, its role cannot be changed.

panic
E32USER-CBase-? When this method is invoked after the server has been started.
CServer2::Start()

Parameters

const CServer2 * aServer

SetPinClientDescriptors(TBool)

IMPORT_C void SetPinClientDescriptors ( TBool aPin )

Sets whether the kernel will pin descriptors passed to this server in the context of the client thread.

Setting this is one way of ensuring that the server will not take page faults when accessing client descriptors, which would otherwise happen if the data was paged out.

This method overrides the default pinning policy of the server which is for the server to pin its client's descriptors if the process creating the server is not data paged. I.e. if CServer2::SetPinClientDescriptors() is not invoked on the server and RProcess::DefaultDataPaged() of the process creating the server returns EFalse, the server will pin its client's descriptors, otherwise the server will not pin its client's descriptors.

This method must be called prior to starting the server by calling the Start() method.

panic
E32USER-CBase 106 When this method is invoked after the server has been started.
CServer2::Start()

Parameters

TBool aPin Set to ETrue for the server to pin its client's descriptors, set to EFalse otherwise.

Start(const TDesC &)

IMPORT_C TInt Start ( const TDesC & aName )

Adds the server with the specified name to the active scheduler, and issues the first request for messages.

If KNullDesC is specified for the name, then an anonymous server will be created. To create a session to such a server, an overload of RSessionBase::CreateSession() which takes RServer2 object as a parameter can be used.

capability
ProtServ if aName starts with a '!' character

Parameters

const TDesC & aName The name of the server. KNullDesC, to create anonymous servers.

StartL(const TDesC &)

IMPORT_C void StartL ( const TDesC & aName )

Adds the server with the specified name to the active scheduler, and issues the first request for messages, and leaves if the operation fails.

If KNullDesC is specified for the name, then an anonymous server will be created. To create a session to such a server, the overload of RSessionBase::CreateSession() which takes an RServer2 object as a parameter can be used.

capability
ProtServ if aName starts with a '!' character

Parameters

const TDesC & aName The name of the server. KNullDesC, to create anonymous servers.

Member Enumerations Documentation

Enum TPanic

Enumerators

EBadMessageNumber
ESessionNotConnected
ESessionAlreadyConnected
EClientDoesntHaveRequiredCaps

Enum TServerType

This enumeration defines the maximum sharability of sessions opened with this server; for backwards compatibilty, these should be have the same values as the corresponding EIpcSessionType enumeration

Enumerators

EUnsharableSessions = EIpcSession_Unsharable
ESharableSessions = EIpcSession_Sharable
EGlobalSharableSessions = EIpcSession_GlobalSharable

Member Data Documentation

RMessage2 iMessage

RMessage2 iMessage [private]

RServer2 iServer

RServer2 iServer [private]

TUint16 iServerOpts

TUint16 iServerOpts [private]

TUint8 iServerRole

TUint8 iServerRole [private]

TDblQueIter< CSession2 > iSessionIter

TDblQueIter < CSession2 > iSessionIter [protected]

TDblQue< CSession2 > iSessionQ

TDblQue < CSession2 > iSessionQ [private]

TUint8 iSessionType

TUint8 iSessionType [private]

TAny * iSpare

TAny * iSpare [private]