00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <e32base.h>
00018 #include "clientserver.h"
00019
00020 enum TMyPanic
00021 {
00022 EPanicBadDescriptor,
00023 EPanicIllegalFunction,
00024 EPanicAlreadyReceiving
00025 };
00026
00027 void PanicClient(const RMessagePtr2& aMessage,TMyPanic TMyPanic);
00028
00029 class CShutdown : public CTimer
00030 {
00031 enum {KMyShutdownDelay=0x200000};
00032 public:
00033 inline CShutdown();
00034 inline void ConstructL();
00035 inline void Start();
00036 private:
00037 void RunL();
00038 };
00039
00040 class CMyServer : public CServer2
00041 {
00042 public:
00043 static CServer2* NewLC();
00044 void AddSession();
00045 void DropSession();
00046 void Send(const TDesC& aMessage);
00047 private:
00048 CMyServer();
00049 void ConstructL();
00050 CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const;
00051 private:
00052 TInt iSessionCount;
00053 CShutdown iShutdown;
00054 };
00055
00056 class CMySession : public CSession2
00057 {
00058 public:
00059 CMySession();
00060 void CreateL();
00061 void Send(const TDesC& aMessage);
00062 private:
00063 ~CMySession();
00064 inline CMyServer& Server();
00065 void ServiceL(const RMessage2& aMessage);
00066 void ServiceError(const RMessage2& aMessage,TInt aError);
00067 inline TBool ReceivePending() const;
00068 private:
00069 RMessagePtr2 iReceiveMsg;
00070 TInt iReceiveLen;
00071 };
00072