00001 // Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies). 00002 // All rights reserved. 00003 // This component and the accompanying materials are made available 00004 // under the terms of "Eclipse Public License v1.0" 00005 // which accompanies this distribution, and is available 00006 // at the URL "http://www.eclipse.org/legal/epl-v10.html". 00007 // 00008 // Initial Contributors: 00009 // Nokia Corporation - initial contribution. 00010 // 00011 // Contributors: 00012 // 00013 // Description: 00014 // Transient server example - server classes 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}; // approx 2s 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
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.