00001 /* 00002 * serversideasynch.h,v 1.10 2003/12/27 19:46:23 matti 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 00037 // base class for asynchronous call handlers 00039 class CAsynchBase : public CActive 00040 { 00041 public: 00042 CAsynchBase(CConcreteConnection *aConnection); 00043 virtual ~CAsynchBase(); 00044 00045 protected: 00046 00047 // reference to the concrete connection (socket wrapper) 00048 CConcreteConnection *iConnection; 00049 00050 // current pending client call message 00051 RMessage iMessage; 00052 }; 00053 00055 // asynchronous Send handler 00057 class CAsynchSend : public CAsynchBase 00058 { 00059 public: 00060 CAsynchSend(CConcreteConnection *aConnection); 00061 //~CAsynchSend(); 00062 00063 void SendL(TDesC8 *aBuf); 00064 void SendL(RPointerArray<TDesC8> *aFragments); 00065 00066 // from CActive 00067 void RunL(); 00068 void DoCancel(); 00069 TInt RunError(TInt aError); 00070 00071 private: 00072 void SendFragmentL(TDesC8 *aBuf); 00073 void CleanBuffers(); 00074 00075 // buffer being sent, class holds a reference to it 00076 // as it is responsible for deleting it. 00077 TDesC8 *iSendBuf; 00078 00079 // An array containing all fragments of the given 00080 // buffer if its size exceeds the MTU 00081 RPointerArray<TDesC8> *iFragments; 00082 00083 // Amount of fragments waiting for sending 00084 TInt iFragmentCount; 00085 }; 00086 00088 // asynchronous Receive handler 00090 class CAsynchReceive : public CAsynchBase 00091 { 00092 public: 00093 CAsynchReceive(CConcreteConnection *aConnection); 00094 // ~CAsynchReceive(); 00095 00096 void Receive(const RMessage &aMessage); 00097 00098 // from CActive 00099 void RunL(); 00100 void DoCancel(); 00101 TInt RunError(TInt aError); 00102 private: 00103 // receive buffer 00104 TBuf8<KRecvBufSize> iRecvBuf; 00105 TSockXfrLength iRecvLen; 00106 }; 00107 00109 // asynchronous Listen handler 00111 class CAsynchListen : public CAsynchBase 00112 { 00113 public: 00114 CAsynchListen(CConcreteConnection *aConnection); 00115 ~CAsynchListen(); 00116 00117 void ListenL(const RMessage &aMessage); 00118 00119 // from CActive 00120 void RunL(); 00121 void DoCancel(); 00122 TInt RunError(TInt aError); 00123 00124 private: 00125 RSocket *iIncomingSocket; 00126 }; 00127 00128 #endif
1.3.5