Symbian
Symbian OS Library

SYMBIAN OS V9.3

[Index] [Spacer] [Previous] [Next]



Location: e32base.h
Link against: euser.lib

Class CServer2

class CServer2 : public CActive;

Description

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)

Derivation

Members

Defined in CServer2:
CServer2(), DoCancel(), DoConnect(), EGlobalSharableSessions, ESharableSessions, EUnsharableSessions, Extension_(), Message(), NewSessionL(), ReStart(), RunError(), RunL(), Server(), Start(), StartL(), TServerType, iSessionIter, ~CServer2()

Inherited from CActive:
Cancel(), Deque(), EPriorityHigh, EPriorityIdle, EPriorityLow, EPriorityStandard, EPriorityUserInput, IsActive(), IsAdded(), Priority(), SetActive(), SetPriority(), TPriority, iStatus

Inherited from CBase:
Delete(), operator new()


Construction and destruction


~CServer2()

virtual IMPORT_C ~CServer2()=0;

Description

Frees resources prior to destruction.

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


CServer2()

protected: IMPORT_C CServer2(TInt aPriority, TServerType aType=EUnsharableSessions);

Description

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

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.

[Top]


Member functions


Start()

Capability: ProtServ if aName starts with a '!' character

IMPORT_C TInt Start(const TDesC &aName);

Description

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

Parameters

const TDesC &aName

The name of the server.

Return value

TInt

KErrNone, if successful, otherwise one of the other system wide error codes.


StartL()

Capability: ProtServ if aName starts with a '!' character

IMPORT_C void StartL(const TDesC &aName);

Description

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

Parameters

const TDesC &aName

The name of the server.


ReStart()

IMPORT_C void ReStart();

Description

Restarts the server.

The function issues a request for messages.


Server()

inline RServer2 Server() const;

Description

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.

Return value

RServer2

The handle to the server.


Message()

protected: inline const RMessage2 &Message() const;

Description

Gets a reference to the server's current message.

Return value

const RMessage2 &

The current message that contains the client request details.


DoCancel()

protected: virtual IMPORT_C void DoCancel();

Description

Implements the cancellation of any outstanding request for messages.


RunL()

protected: virtual IMPORT_C void RunL();

Description

Handles the receipt of a message.


RunError()

protected: virtual IMPORT_C TInt RunError(TInt aError);

Description

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.

Parameters

TInt aError

The leave code.

Return value

TInt

KErrNone.

See also:


DoConnect()

protected: virtual IMPORT_C void DoConnect(const RMessage2 &aMessage);

Description

Handles the connect request from the client.

Parameters

const RMessage2 &aMessage

Represents the details of the client request that is requesting the connection.


Extension_()

protected: virtual IMPORT_C TInt Extension_(TUint aExtensionId, TAny *&a0, TAny *a1);

Description

Extension function

Parameters

TUint aExtensionId

TAny *&a0

TAny *a1

Return value

TInt


NewSessionL()

private: virtual IMPORT_C CSession2 *NewSessionL(const TVersion &aVersion, const RMessage2 &aMessage) const=0;

Description

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:

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.

Return value

CSession2 *

A pointer to the newly created server-side session object.

See also:

[Top]


Member enumerations


Enum TServerType

TServerType

Description

Defines the set of session types that the server can create.

A specific session type is specified when the CServer2 object is created.

EUnsharableSessions

The session is not sharable with other threads.

ESharableSessions

The session is sharable with other threads in the same process.

EGlobalSharableSessions

The session is sharable with all other threads in the system.

[Top]


Member data


iSessionIter

protected: TDblQueIter< CSession2 > iSessionIter;

Description