|
||
class CSession2 : public CBase;
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:
restricted to the creating thread
can be shared with other threads in the same process
can be shared by all threads in the system.
A server must define and implement a derived class. In particular, it must provide an implementation for the CSession2::ServiceL(const RMessage2 &)
virtual function.
(Note that this class should be used instead of CSession)
CBase
-
Base class for all classes to be instantiated on the heap.
CSession2
-
Represents a session (version 2) for a client thread on the server-side.
Defined in CSession2
:
CSession2()
Default constructor.CountResources()
Gets the number of resources currently in use.CreateL()
Completes construction of this server-side client session object.Disconnect(const RMessage2 &)
Called by a server when it receives a disconnect message for the session.Extension_(TUint,TAny *&,TAny *)
Extension function ResourceCountMarkEnd(const RMessage2 &)
Marks the end of resource count checking.ResourceCountMarkStart()
Marks the start of resource count checking.Server()const
Gets the server active object that handles messages for this session.ServiceError(const RMessage2 &,TInt)
Handles the situation when a call to CSession2::ServiceL(const RMessage2 &),...ServiceL(const RMessage2 &)
Handles the servicing of a client request that has been passed to the server.~CSession2()
Destructor.Inherited from CBase
:
Delete(CBase *)
Deletes the specified object.operator new(TUint)
Allocates the object from the heap and then initialises its contents to binary z...operator new(TUint,TAny *)
Initialises the object to binary zeroes.operator new(TUint,TLeave)
Allocates the object from the heap and then initialises its contents to binary z...operator new(TUint,TLeave,TUint)
Allocates the object from the heap and then initialises its contents to binary z...operator new(TUint,TUint)
Allocates the object from the heap and then initialises its contents to binary z...IMPORT_C virtual ~CSession2()=0;
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.
private: IMPORT_C virtual void CreateL();
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.
CServer2::NewSessionL(const TVersion &,const RMessage2 &)const
Creates a server-side session object.inline const CServer2* Server() const;
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.
|
IMPORT_C void ResourceCountMarkStart();
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(const RMessage2 &)
is called at some later time.
The client/server framework does not call this function (nor does it call CSession2::ResourceCountMarkEnd(const RMessage2 &)
), but is available for servers to use, if appropriate.
CSession2::CountResources()
Gets the number of resources currently in use.CSession2::ResourceCountMarkEnd(const RMessage2 &)
Marks the end of resource count checking.IMPORT_C void ResourceCountMarkEnd(const RMessage2 &aMessage);
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.
|
CSession2::CountResources()
Gets the number of resources currently in use.CSession2::ResourceCountMarkStart()
Marks the start of resource count checking.IMPORT_C virtual TInt CountResources();
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.
|
virtual void ServiceL(const RMessage2 &aMessage)=0;
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.
|
IMPORT_C virtual void ServiceError(const RMessage2 &aMessage, TInt aError);
Handles the situation when a call to CSession2::ServiceL(const RMessage2 &)
, which services a client request, leaves.
Servers are active objects, and the call to CSession2::ServiceL(const RMessage2 &)
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 CSession2::ServiceError(const RMessage2 &,TInt)
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.
|
CActive::RunL()
Handles an active object's request completion event.CActive::RunError(TInt)
Handles a leave occurring in the request completion event handler CActive::RunL(...protected: IMPORT_C virtual void Disconnect(const RMessage2 &aMessage);
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
'this' session object has been deleted.
|