# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

callback_server.h

Go 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_SERVER_H
00027 #define NL_CALLBACK_SERVER_H
00028 
00029 #include "nel/misc/types_nl.h"
00030 
00031 #include "nel/net/callback_net_base.h"
00032 #include "nel/net/buf_server.h"
00033 
00034 
00035 namespace NLNET {
00036 
00037 
00044 class CCallbackServer : public CCallbackNetBase, public CBufServer
00045 {
00046 public:
00047 
00049         CCallbackServer( TRecordingState rec=Off, const std::string& recfilename="", bool recordall=true );
00050 
00052         void    send (const CMessage &buffer, TSockId hostid, bool log = true);
00053 
00055         bool    flush (TSockId destid) { checkThreadId (); nlassert( destid != InvalidSockId ); return CBufServer::flush(destid); }
00056 
00058         void    update (sint32 timeout=0);
00059 
00061         void    setConnectionCallback (TNetCallback cb, void *arg) { checkThreadId (); _ConnectionCallback = cb; _ConnectionCbArg = arg; }
00062 
00064         void    setDisconnectionCallback (TNetCallback cb, void *arg) { checkThreadId (); CCallbackNetBase::setDisconnectionCallback (cb, arg); }
00065 
00067         bool    connected () const { checkThreadId (); return true; } 
00068 
00074         void    disconnect (TSockId hostid);
00075 
00077         const CInetAddress& hostAddress (TSockId hostid) { nlassert(hostid!=InvalidSockId); checkThreadId(); return CBufServer::hostAddress (hostid); }
00078 
00080         virtual TSockId getSockId (TSockId hostid = InvalidSockId);
00081 
00082         uint64  getReceiveQueueSize () { return CBufServer::getReceiveQueueSize(); }
00083         uint64  getSendQueueSize () { return CBufServer::getSendQueueSize(0); }
00084 
00085 private:
00086 
00088         void                    send (const NLMISC::CMemStream &buffer, TSockId hostid) { nlstop; }
00089 
00090         bool                    dataAvailable ();
00091         void                    receive (CMessage &buffer, TSockId *hostid);
00092 
00093         void                    sendAllMyAssociations (TSockId to);
00094 
00095         TNetCallback    _ConnectionCallback;
00096         void                    *_ConnectionCbArg;
00097 
00098         friend void             cbsNewConnection (TSockId from, void *data);
00099 
00100         // ---------------------------------------
00101 #ifdef USE_MESSAGE_RECORDER
00102         void                                            noticeConnection( TSockId hostid );
00103         virtual                                         bool replaySystemCallbacks();
00104         std::vector<CBufSock*>          _MR_Connections;
00105         std::map<TSockId,TSockId>       _MR_SockIds; // first=sockid in file; second=CBufSock*
00106 #endif
00107         // ---------------------------------------
00108         
00109 };
00110 
00111 
00112 } // NLNET
00113 
00114 
00115 #endif // NL_CALLBACK_SERVER_H
00116 
00117 /* End of callback_server.h */