Home | nevrax.com |
|
callback_client.hGo to the documentation of this file.00001 00007 /* Copyright, 2001 Nevrax Ltd. 00008 * 00009 * This file is part of NEVRAX NEL. 00010 * NEVRAX NEL is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2, or (at your option) 00013 * any later version. 00014 00015 * NEVRAX NEL is distributed in the hope that it will be useful, but 00016 * WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 * General Public License for more details. 00019 00020 * You should have received a copy of the GNU General Public License 00021 * along with NEVRAX NEL; see the file COPYING. If not, write to the 00022 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, 00023 * MA 02111-1307, USA. 00024 */ 00025 00026 #ifndef NL_CALLBACK_CLIENT_H 00027 #define NL_CALLBACK_CLIENT_H 00028 00029 #include "nel/misc/types_nl.h" 00030 00031 #include "nel/net/callback_net_base.h" 00032 #include "nel/net/buf_client.h" 00033 00034 namespace NLNET { 00035 00036 00037 class CInetAddress; 00038 00039 00046 class CCallbackClient : public CCallbackNetBase, public CBufClient 00047 { 00048 public: 00049 00051 CCallbackClient( TRecordingState rec=Off, const std::string& recfilename="", bool recordall=true ); 00052 00054 void send (const CMessage &buffer, TSockId hostid = InvalidSockId, bool log = true); 00055 00057 bool flush (TSockId hostid = InvalidSockId); 00058 00060 void update ( sint32 timeout=0 ); 00061 00063 void connect( const CInetAddress& addr ); 00064 00069 virtual bool connected () const { checkThreadId (); return CBufClient::connected (); } 00070 00071 virtual const CInetAddress& hostAddress( TSockId hostid ) { return remoteAddress(); } 00072 00077 void disconnect (TSockId hostid = InvalidSockId); 00078 00080 void setDisconnectionCallback (TNetCallback cb, void *arg) { checkThreadId (); CCallbackNetBase::setDisconnectionCallback (cb, arg); } 00081 00083 virtual TSockId getSockId (TSockId hostid = InvalidSockId); 00084 00085 uint64 getReceiveQueueSize () { return CBufClient::getReceiveQueueSize(); } 00086 uint64 getSendQueueSize () { return CBufClient::getSendQueueSize(); } 00087 00088 private: 00089 00091 void send (const NLMISC::CMemStream &buffer) { nlstop; } 00092 00094 bool dataAvailable (); 00095 00096 void receive (CMessage &buffer, TSockId *hostid = NULL); 00097 00098 // --------------------------------------- 00099 #ifdef USE_MESSAGE_RECORDER 00100 virtual bool replaySystemCallbacks(); 00101 #endif 00102 00103 00104 // debug features, we number all packet to be sure that they are all sent and received 00105 // \todo remove this debug feature when ok 00106 uint32 SendNextValue, ReceiveNextValue; 00107 }; 00108 00109 00110 } // NLNET 00111 00112 00113 #endif // NL_CALLBACK_CLIENT_H 00114 00115 /* End of callback_client.h */ |