Symbian Developer Library

SYMBIAN OS V6.1 EDITION FOR C++

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



Location: e32base.h
Link against: euser.lib

Class CServer

CServer

Support

Supported from 5.0

Description

Abstract base class for servers.

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 for connection from client threads.

A server must define and implement a derived class.

Derivation

CActiveThe core class of the active object abstraction
CBaseBase class for all classes to be instantiated on the heap
CServerAbstract base class for servers

Defined in CServer:
CServer(), EMultipleSessions, ESharableSessions, ESingleSession, EUnsharableSessions, Message(), NewSessionL(), ReStart(), Start(), StartL(), TServerType, TSessionControl, iControl, iName, iSessionIter, ~CServer()

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

Inherited from CBase:
operator new()


Construction and destruction


CServer()

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

Support

Supported from 6.0

Description

Constructs the server object with the specified 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 whether the server creates sharable sessions or not. By default, the server creates unsharable sessions.


CServer()

protected: CServer(TInt aPriority);

Support

Withdrawn in 6.0

Description

Constructs the server object with the specified 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.


~CServer()

~CServer();

Support

Supported from 6.0

Description

Frees resources prior to destruction. Specifically, it:

See also:


~CServer()

~CServer();

Support

Withdrawn in 6.0

Description

Destructor. This frees resources prior to destruction. Specifically, it:

See also:

[Top]


Starting and re-starting the server


Start()

TInt Start(const TDesC& aName);

Support

Supported from 6.0

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 system wide error codes.


StartL()

void StartL(const TDesC& aName);

Support

Supported from 6.0

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 the operation fails, the function leaves with one of the system-wide error codes.

Parameters

const TDesC& aName

The name of the server.


Start()

TInt Start();

Support

Withdrawn in 6.0

Description

Adds the server to the active scheduler and issues the first request for messages.

The function raises an E32USER-CBase 55 panic, if the server has not been given a name.

Return value

TInt

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


StartL()

void StartL();

Support

Withdrawn in 6.0

Description

Adds the server to the active scheduler and issues the first request for messages. If the operation fails, the function leaves with one of the system wide error codes.

The function raises an E32USER-CBase 55 panic, if the server has not been given a name.


ReStart()

void ReStart();

Description

Re-starts the issuing of requests for messages.

It is necessary to call this, as part of the error recovery procedure, if a server-side client session's service handler leaves. The call is normally made in the server's implementation of the active scheduler error handler.

See also:

[Top]


Message information


Message()

const RMessage& Message() const;

Description

Returns a reference to the server's current message.

Return value

RMessage&

A reference to the server's current message.

[Top]


Creating a client session


NewSessionL()

private: virtual CSharableSession* NewSessionL(const TVersion& aVersion) const = 0;

Support

Supported from 6.0

Description

Creates a server-side client session object.

An implementation of this function should:

This function is called when a client makes a request to connect to the server.

Parameters

const TVersion& aVersion

Version information supplied by the client.

Return value

CSharableSession*

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

See also:


NewSessionL()

protected: virtual CSession* NewSessionL(RThread aClient,const TVersion& aVersion) const = 0;

Support

Withdrawn in 6.0

Description

Creates a server-side client session object for a client thread.

An implementation of this function should:

This function is called when a client makes a request to connect to the server.

Parameters

RThread aClient

The client thread

const TVersion& aVersion

Version information supplied by the client.

Return value

CSession*

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

See also:

[Top]


Data members


iSessionIter

protected: TDblQueIter<CSession> iSessionIter

Description

An iterator for the list of sessions connected to the server.


iControl

TSessionControl iControl

Support

Withdrawn in 6.0

Description

Determines whether a client thread can connect once or more than once to the server.

By default, a client thread can connect to the server more than once.


iName

HBufC* iName

Support

Withdrawn in 6.0

Description

A pointer to a heap descriptor containing the name of the server.

The server cannot be started until the derived class has created a heap descriptor containing the server name. The heap descriptor is deleted by the constructor.

[Top]


Enumerations


Enum TServerType

protected: TServerType

Support

Supported from 6.0

Description

Indicates whether the server creates sharable sessions.

EUnsharableSessions

The server does not create sharable sessions.

ESharableSessions

The server creates sharable sessions.


Enum TSessionControl

TSessionControl

Support

Withdrawn in 6.0

Description

Session type.

ESingleSession

The server allows only one session per client thread.

EMultipleSessions

The server allows multiple sessions per client thread.