00001 /* 00002 * serversideasynch.h,v 1.8 2003/11/20 07:52:21 mattid Exp 00003 * 00004 * COBAIN - Communications API for EPOC Environments 00005 * Copyright (C) 2002-2003 Matti Dahlbom, Matti Kokkola 00006 * 00007 * This library is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2.1 of the License, or (at your option) any later version. 00011 * 00012 * This library is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with this library; if not, write to the Free Software 00019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 * 00021 * Contact: Matti Dahlbom <matti@777-team.org> 00022 * Matti Kokkola <matti.kokkola@iki.fi> 00023 */ 00024 00025 #ifndef __SERVERSIDEASYNCH_H 00026 #define __SERVERSIDEASYNCH_H 00027 00028 #include <e32base.h> 00029 #include <es_sock.h> 00030 00031 #include "clientservercommon.h" 00032 00033 // forward declarations 00034 class CConcreteConnection; 00035 00036 // base class for asynchronous call handlers 00037 class CAsynchBase : public CActive 00038 { 00039 public: 00040 CAsynchBase(CConcreteConnection *aConnection); 00041 virtual ~CAsynchBase(); 00042 00043 protected: 00044 00045 // reference to the concrete connection (socket wrapper) 00046 CConcreteConnection *iConnection; 00047 00048 // current pending client call message 00049 RMessage iMessage; 00050 }; 00051 00052 // asynchronous Send handler 00053 class CAsynchSend : public CAsynchBase 00054 { 00055 public: 00056 CAsynchSend(CConcreteConnection *aConnection); 00057 //~CAsynchSend(); 00058 00059 void SendL(TDesC8 *aBuf); 00060 00061 // from CActive 00062 void RunL(); 00063 void DoCancel(); 00064 TInt RunError(TInt aError); 00065 00066 private: 00067 // buffer being sent 00068 TDesC8 *iSendBuf; 00069 }; 00070 00071 // asynchronous Receive handler 00072 class CAsynchReceive : public CAsynchBase 00073 { 00074 public: 00075 CAsynchReceive(CConcreteConnection *aConnection); 00076 // ~CAsynchReceive(); 00077 00078 void Receive(const RMessage &aMessage); 00079 00080 // from CActive 00081 void RunL(); 00082 void DoCancel(); 00083 TInt RunError(TInt aError); 00084 private: 00085 // receive buffer 00086 TBuf8<KRecvBufSize> iRecvBuf; 00087 TSockXfrLength iRecvLen; 00088 }; 00089 00090 // asynchronous Listen handler 00091 class CAsynchListen : public CAsynchBase 00092 { 00093 public: 00094 CAsynchListen(CConcreteConnection *aConnection); 00095 ~CAsynchListen(); 00096 00097 void ListenL(const RMessage &aMessage); 00098 00099 // from CActive 00100 void RunL(); 00101 void DoCancel(); 00102 TInt RunError(TInt aError); 00103 00104 private: 00105 RSocket *iIncomingSocket; 00106 }; 00107 00108 #endif
1.3.5