hercules v9 symbian os application development

源代码在线查看: server.h

软件大小: 66 K
上传用户: dtlyzx
关键词: application development hercules symbian
下载地址: 免注册下载 普通下载 VIP

相关代码

				// server.h
				#ifndef __SERVER_H__
				#define __SERVER_H__
				
				#include 
				#include "client-server.h"
				
				enum TServerPanic
					{
					EPanicBadDescriptor,
					EPanicNotSupported
					};
				
				void PanicClient(const RMessage2& aMessage,TServerPanic TMyPanic);
				
				const TInt KShutdownDelay=200000; // approx 2 seconds
				class CShutdown : public CTimer
					{
				public:
					inline CShutdown();
					inline void ConstructL();
					inline void Start();
				private:
					void RunL();
					};
				
				
				inline CShutdown::CShutdown()
					:CTimer(-1)
					{CActiveScheduler::Add(this);}
				inline void CShutdown::ConstructL()
					{CTimer::ConstructL();}
				inline void CShutdown::Start()
					{After(KShutdownDelay);}
				
				
				class CHerculeanServer : public CServer2
					{
				public:
					static CServer2* NewLC();
					void AddSession();
					void RemoveSession();
				private:
					CHerculeanServer();
					void ConstructL();
					// From CServer2
					virtual CSession2* NewSessionL(const TVersion& aVersion,const RMessage2& aMessage) const; 
				private:
					TInt iSessionCount;
					CShutdown iShutdown;
					};
				
				
				inline CHerculeanServer::CHerculeanServer()
					:CServer2(CActive::EPriorityStandard)
					{}
				
				
				class CAsyncHandler; // Active object class for asynchronous requests
				
				class CHerculeanSession : public CSession2
					{
				public:
					CHerculeanSession();
					void CreateL();
				public:
					virtual void ServiceL(const RMessage2& aMessage); // From CSession2
					virtual void ServiceError(const RMessage2& aMessage, TInt aError); // From CSession2
				private:
					void SlayNemeanLionL(const RMessage2& aMessage);
					void SlayHydraL(const RMessage2& aMessage);
					void CaptureCeryneianHindL(const RMessage2& aMessage);
					void SlayErymanthianBoarL(const RMessage2& aMessage);
					void CleanAugeanStablesL(const RMessage2& aMessage);
					void CancelCleanAugeanStables(const RMessage2& aMessage);
					void SlayStymphalianBirdsL(const RMessage2& aMessage);
					void CancelSlayStymphalianBirds(const RMessage2& aMessage);
				private:
					~CHerculeanSession();
				private:
					CAsyncHandler* iAsyncRequestHandler;
					HBufC8* iClientBuf;
					};
				
				inline CHerculeanSession::CHerculeanSession()
					{}
				
				
				// Skeleton active object, for asynchronous server requests
				// Uses a very basic timer for asynchronicity
				class CAsyncHandler : public CActive
					{
				public:
					static CAsyncHandler* NewL();
					static CAsyncHandler* NewLC();
					~CAsyncHandler();
				public:
					void ServiceAsyncRequest(const RMessage2& aMessage);
				protected:
					CAsyncHandler();
					void ConstructL();
				private:
					void DoCancel();
					void RunL();
				private:
					RTimer iTimer;
					RMessage2 iMessage;
					};
				
				
				#endif //__SERVER_H__
				
							

相关资源