From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- .../doxygen/nel/callback__net__base_8h-source.html | 252 +++++++++++++++++++++ 1 file changed, 252 insertions(+) create mode 100644 docs/doxygen/nel/callback__net__base_8h-source.html (limited to 'docs/doxygen/nel/callback__net__base_8h-source.html') diff --git a/docs/doxygen/nel/callback__net__base_8h-source.html b/docs/doxygen/nel/callback__net__base_8h-source.html new file mode 100644 index 00000000..28fe8da3 --- /dev/null +++ b/docs/doxygen/nel/callback__net__base_8h-source.html @@ -0,0 +1,252 @@ + + + + nevrax.org : docs + + + + + + + + + + + + + + +
# 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_net_base.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_NET_BASE_H
+00027 #define NL_CALLBACK_NET_BASE_H
+00028 
+00029 #undef USE_MESSAGE_RECORDER
+00030 
+00031 #include "nel/misc/types_nl.h"
+00032 #include "nel/misc/time_nl.h"
+00033 
+00034 #include "nel/net/buf_net_base.h"
+00035 #include "nel/net/message.h"
+00036 #include "nel/net/inet_address.h"
+00037 
+00038 #ifdef USE_MESSAGE_RECORDER
+00039 #include "nel/net/message_recorder.h"
+00040 #include <queue>
+00041 #endif
+00042 
+00043 #include <vector>
+00044 
+00045 
+00046 namespace NLNET {
+00047 
+00048 class CCallbackNetBase;
+00049 
+00055 typedef void (*TMsgCallback) (CMessage &msgin, TSockId from, CCallbackNetBase &netbase);
+00056 
+00057 
+00059 typedef struct
+00060 {
+00062         char                    *Key;
+00064         TMsgCallback    Callback;
+00065 
+00066 } TCallbackItem;
+00067 
+00068 
+00075 class CCallbackNetBase
+00076 {
+00077 public:
+00078         virtual ~CCallbackNetBase() {}
+00079 
+00080 
+00085         virtual void    send (const CMessage &buffer, TSockId hostid = InvalidSockId, bool log = true) = 0;
+00086 
+00087         uint64  getBytesSent () { return _BytesSent; }
+00088         uint64  getBytesReceived () { return _BytesReceived; }
+00089 
+00090         virtual uint64  getReceiveQueueSize () = 0;
+00091         virtual uint64  getSendQueueSize () = 0;
+00092 
+00097         virtual bool    flush (TSockId hostid = InvalidSockId) = 0;
+00098         
+00102         void    addCallbackArray (const TCallbackItem *callbackarray, NLMISC::CStringIdArray::TStringId arraysize);
+00103 
+00105         void    setDefaultCallback(TMsgCallback defaultCallback) { _DefaultCallback = defaultCallback; }
+00106 
+00108         void    setDisconnectionCallback (TNetCallback cb, void *arg) { checkThreadId ();  _DisconnectionCallback = cb; _DisconnectionCbArg = arg; }
+00109 
+00111         virtual TSockId getSockId (TSockId hostid = InvalidSockId) = 0;
+00112 
+00118         void    authorizeOnly (const char *callbackName, TSockId hostid = InvalidSockId);
+00119 
+00121         bool    isAServer () const { checkThreadId (); return _IsAServer; }
+00122 
+00124         NLMISC::CStringIdArray  &getSIDA () { return _InputSIDA; }
+00125 
+00127         virtual bool    dataAvailable () { nlstop; return false; }
+00129         virtual void    update ( sint32 timeout=0 ) { nlstop; }
+00131         virtual bool    connected () const { nlstop; return false; }
+00133         virtual void    disconnect (TSockId hostid = InvalidSockId) { nlstop; }
+00134 
+00136         virtual const   CInetAddress& hostAddress (TSockId hostid);
+00137 
+00139         void    sendAllMyAssociations (TSockId to);
+00140 
+00145         void    setOtherSideAssociations (const char **associationarray, NLMISC::CStringIdArray::TStringId arraysize);
+00146 
+00147         void    displayAllMyAssociations ();
+00148 
+00152         void    ignoreAllUnknownId(bool b)
+00153         {
+00154                 _InputSIDA.ignoreAllUnknownId (b);
+00155         }
+00156 
+00157         // Defined even when USE_MESSAGE_RECORDER is not defined
+00158         enum TRecordingState { Off, Record, Replay };
+00159 
+00160 protected:
+00161 
+00162         uint64  _BytesSent, _BytesReceived;
+00163 
+00165         TNetCallback _NewDisconnectionCallback;
+00166 
+00168         CCallbackNetBase( TRecordingState rec=Off, const std::string& recfilename="", bool recordall=true );
+00169 
+00171         void baseUpdate ( sint32 timeout=0 );
+00172 
+00174         void processOneMessage ();
+00175 
+00177         virtual void    receive (CMessage &buffer, TSockId *hostid) = 0;
+00178 
+00179         /* It's the layer4 that full the buffer association because it's based on callback system
+00180          * this is message association used when received a message number from the socket to know the
+00181          * associated message name
+00182          */
+00183         NLMISC::CStringIdArray _InputSIDA;
+00184 
+00185         /* It's the layer4 that full the buffer association because it's based on callback system
+00186          * this is message association used when you want to send a message to a socket
+00187          */
+00188         NLMISC::CStringIdArray _OutputSIDA;
+00189 
+00190         // contains callbacks
+00191         std::vector<TCallbackItem>      _CallbackArray;
+00192         
+00193         // called if the received message is not found in the callback array
+00194         TMsgCallback                            _DefaultCallback;
+00195 
+00196         bool _IsAServer;
+00197         bool _FirstUpdate;
+00198 
+00199         // ---------------------------------------
+00200 #ifdef USE_MESSAGE_RECORDER
+00201         bool                    replayDataAvailable();
+00202         virtual bool    replaySystemCallbacks() = 0;
+00203         void                    noticeDisconnection( TSockId hostid );
+00204 
+00205         TRecordingState                                         _MR_RecordingState;
+00206         sint64                                                          _MR_UpdateCounter;
+00207 
+00208         CMessageRecorder                                        _MR_Recorder;
+00209 #endif
+00210         // ---------------------------------------
+00211 
+00212 private:
+00213 
+00214         NLMISC::TTime           _LastUpdateTime;
+00215         NLMISC::TTime           _LastMovedStringArray;
+00216         
+00217         TNetCallback             _DisconnectionCallback;
+00218         void                            *_DisconnectionCbArg;
+00219 
+00220         friend void cbnbMessageAskAssociations (CMessage &msgin, TSockId from, CCallbackNetBase &netbase);
+00221         friend void cbnbMessageRecvAssociations (CMessage &msgin, TSockId from, CCallbackNetBase &netbase);
+00222 
+00223         friend void cbnbNewDisconnection (TSockId from, void *data);
+00224 
+00225 protected:
+00227         uint    _ThreadId;
+00228         void    checkThreadId () const;
+00229 };
+00230 
+00231 
+00232 } // NLNET
+00233 
+00234 
+00235 #endif // NL_CALLBACK_NET_BASE_H
+00236 
+00237 /* End of callback_net_base.h */
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1