Symbian
Symbian Developer Library

SYMBIAN OS V9.4

Feedback

[Index] [Previous] [Next]

#include <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:

Inherited from CActive:

Inherited from CBase:


Construction and destruction


~CServer2()

IMPORT_C virtual ~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(TInt,TServerType)

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.

CServer2::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(const TDesC &)

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.

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(const TDesC &,const TVersion &) which takes RServer2 object as a parameter can be used.

Parameters

const TDesC16 &aName

The name of the server. KNullDesC, to create anonymous servers.

Return value

TInt

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


StartL(const TDesC &)

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.

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(const TDesC &,const TVersion &) which takes an RServer2 object as a parameter can be used.

Parameters

const TDesC16 &aName

The name of the server. KNullDesC, to create anonymous servers.


ReStart()

IMPORT_C void ReStart();

Description

Restarts the server.

The function issues a request for messages.


Server()const

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(const TDesC &,const TVersion &) variants that take a server handle.

Return value

RServer2

The handle to the server.


Message()const

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: IMPORT_C virtual void DoCancel();

Description

Implements the cancellation of any outstanding request for messages.


RunL()

protected: IMPORT_C virtual void RunL();

Description

Handles the receipt of a message.


RunError(TInt)

protected: IMPORT_C virtual 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 CServer2::RunError(TInt) function.

In practice, the leave can only be caused by a session's ServiceL() function, which is called from this CServer2::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(const RMessage2 &)

protected: IMPORT_C virtual 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_(TUint,TAny *&,TAny *)

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

Description

Extension function

Parameters

TUint aExtensionId

TAny *&a0

TAny *a1

Return value

TInt


NewSessionL(const TVersion &,const RMessage2 &)const

private: IMPORT_C virtual 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(const TDesC &,const TVersion &) 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