Symbian
Symbian OS Library

SYMBIAN OS V9.3

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



Location: e32base.h
Link against: euser.lib

Class CSession2

class CSession2 : public CBase;

Description

Represents a session (version 2) for a client thread on the server-side.

A session acts as a channel of communication between the client and the server. A client thread can have multiple concurrent sessions with a server.

A session can be:

A server must define and implement a derived class. In particular, it must provide an implementation for the ServiceL() virtual function.

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

Derivation

Members

Defined in CSession2:
CSession2(), CountResources(), CreateL(), Disconnect(), Extension_(), ResourceCountMarkEnd(), ResourceCountMarkStart(), Server(), ServiceError(), ServiceL(), ~CSession2()

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


Construction and destruction


~CSession2()

virtual IMPORT_C ~CSession2()=0;

Description

Destructor.

It frees resources prior to destruction of the object. Specifically, it removes this session object from the server active object’s list of sessions.


CSession2()

protected: IMPORT_C CSession2();

Description

Default constructor.

This constructor is empty.

[Top]


Member functions


CreateL()

private: virtual IMPORT_C void CreateL();

Description

Completes construction of this server-side client session object.

The function is called by the server active object, the CServer2 derived class instance, when a client makes a connection request.

The connection request results in the creation of this session object, followed by a call to this function.

The default implementation is empty.

See also:


Server()

inline const CServer2 *Server() const;

Description

Gets the server active object that handles messages for this session.

This is the instance of the CServer2 derived class that created this session object.

Return value

const CServer2 *

The server active object.


ResourceCountMarkStart()

IMPORT_C void ResourceCountMarkStart();

Description

Marks the start of resource count checking.

It sets up a starting value for resource count checking.

The function sets up a starting value for resource count checking by using the value returned by a call to CSession2::CountResources(), and is the value that will be used for comparison if CSession2::ResourceCountMarkEnd() is called at some later time.

The client/server framework does not call this function (nor does it call CSession2::ResourceCountMarkEnd()), but is available for servers to use, if appropriate.

See also:


ResourceCountMarkEnd()

IMPORT_C void ResourceCountMarkEnd(const RMessage2 &aMessage);

Description

Marks the end of resource count checking.

The function takes the current resource count by calling CSession2::CountResources(), and compares it with the resource count value saved when CSession2::ResourceCountMarkStart() was called. If the resource counts differ, then the client thread is panicked (CSession 2)".

The client/server framework does not call this function (nor does it call CSession2::ResourceCountMarkStart()), but the function is available for servers to use, if appropriate.

Parameters

const RMessage2 &aMessage

Represents the details of the client request that is requesting this resource check.

See also:


CountResources()

virtual IMPORT_C TInt CountResources();

Description

Gets the number of resources currently in use.

Derived classes must provide a suitable implementation. The meaning of a resource depends on the design intent of the server.

The default implementation panics the calling thread (CSession 1) before returning KErrGeneral.

Return value

TInt

The current number of resources in use.


ServiceL()

virtual void ServiceL(const RMessage2 &aMessage)=0;

Description

Handles the servicing of a client request that has been passed to the server.

This function must be implemented in a derived class. The details of the request are contained within the message.

Parameters

const RMessage2 &aMessage

The message containing the details of the client request.


ServiceError()

virtual IMPORT_C void ServiceError(const RMessage2 &aMessage, TInt aError);

Description

Handles the situation when a call to CSession2::ServiceL(), which services a client request, leaves.

Servers are active objects, and the call to CSession2::ServiceL() to handle a client request is executed as part of the server's active object RunL() function. If the RunL() leaves, the active object framework calls the active object's RunError() function. The server framework implements this as a call to ServiceError()

The default behaviour of this function is to complete the message, using the leave value, if it has not already been completed.

Servers can re-implement this as appropriate.

Parameters

const RMessage2 &aMessage

The message containing the details of the client request that caused the leave.

TInt aError

The leave code.

See also:


Disconnect()

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

Description

Called by a server when it receives a disconnect message for the session.

This message is sent by the kernel when all client handles to the session have been closed. This method deletes the session object and completes the disconnect message.

A derived session implementation may overide this virtual method if it needs to perform any asynchronous cleanup actions, these actions must end with a call to the base class implementation of this method, which will delete the session object and complete the disconnect message

Post-Condition

'this' session object has been deleted.

Parameters

const RMessage2 &aMessage

The disconnect message.


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