From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/message__recorder_8h-source.html | 226 ++++++++++++++++++++++ 1 file changed, 226 insertions(+) create mode 100644 docs/doxygen/nel/message__recorder_8h-source.html (limited to 'docs/doxygen/nel/message__recorder_8h-source.html') diff --git a/docs/doxygen/nel/message__recorder_8h-source.html b/docs/doxygen/nel/message__recorder_8h-source.html new file mode 100644 index 00000000..d9e0d5db --- /dev/null +++ b/docs/doxygen/nel/message__recorder_8h-source.html @@ -0,0 +1,226 @@ + + + + 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  
+

message_recorder.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_MESSAGE_RECORDER_H
+00027 #define NL_MESSAGE_RECORDER_H
+00028 
+00029 #include "nel/misc/types_nl.h"
+00030 #include "nel/net/buf_net_base.h"
+00031 //#include "nel/net/callback_net_base.h"
+00032 #include "nel/net/message.h"
+00033 #include "nel/misc/time_nl.h"
+00034 #include "nel/misc/mem_stream.h"
+00035 
+00036 #include <fstream>
+00037 #include <queue>
+00038 #include <string>
+00039 
+00040 using namespace std;
+00041 
+00042 
+00043 namespace NLNET {
+00044 
+00045 
+00046 class CInetAddress;
+00047 
+00049 enum TNetworkEvent { Sending, Receiving, Connecting, ConnFailing, Accepting, Disconnecting, Error };
+00050 
+00051 
+00053 string EventToString( TNetworkEvent e );
+00054 
+00056 TNetworkEvent StringToEvent( string& s );
+00057 
+00058 
+00059 /*
+00060  * TMessageRecord 
+00061  */
+00062 struct TMessageRecord
+00063 {
+00065         TMessageRecord( bool input = false ) : UpdateCounter(0), SockId(NULL), Message( "", input ) {}
+00066 
+00068         TMessageRecord( TNetworkEvent event, TSockId sockid, CMessage& msg, sint64 updatecounter ) :
+00069                 Event(event), SockId(sockid), Message(msg), UpdateCounter(updatecounter) {}
+00070 
+00072         void serial( NLMISC::CMemStream& stream )
+00073         {
+00074                 nlassert( stream.stringMode() );
+00075                 
+00076                 uint32 len;
+00077                 string s_event;
+00078                 stream.serial( UpdateCounter );
+00079                 if ( stream.isReading() )
+00080                 {
+00081                         stream.serial( s_event );
+00082                         Event = StringToEvent( s_event );
+00083                         stream.serialHex( (uint32&)SockId );
+00084                         stream.serial( len );
+00085                         stream.serialBuffer( Message.bufferToFill( len ), len );
+00086                 }
+00087                 else
+00088                 {
+00089                         s_event = EventToString( Event );
+00090                         stream.serial( s_event );
+00091                         stream.serialHex( (uint32&)SockId );
+00092                         len = Message.length();
+00093                         stream.serial( len );
+00094                         stream.serialBuffer( const_cast<uint8*>(Message.buffer()), len ); // assumes the message contains plain text
+00095                 }
+00096         }
+00097 
+00098         //NLMISC::TTime         Time;
+00099         sint64                          UpdateCounter;
+00100         TNetworkEvent           Event;
+00101         TSockId                         SockId;
+00102         CMessage                        Message;
+00103 };
+00104 
+00105 
+00106 
+00116 class CMessageRecorder
+00117 {
+00118 public:
+00119 
+00121         CMessageRecorder();
+00122 
+00124         ~CMessageRecorder();
+00125 
+00127         bool    startRecord( const std::string& filename, bool recordall=true );
+00128 
+00130         void    recordNext( sint64 updatecounter, TNetworkEvent event, TSockId sockid, CMessage& message );
+00131 
+00133         void    stopRecord();
+00134 
+00136         bool    startReplay( const std::string& filename );
+00137 
+00139         void    replayNextDataAvailable( sint64 updatecounter );
+00140 
+00145         TNetworkEvent   checkNextOne( sint64 updatecounter );
+00146 
+00148         TNetworkEvent   replayConnectionAttempt( const CInetAddress& addr );
+00149 
+00151         void    stopReplay();
+00152 
+00154         std::queue<NLNET::TMessageRecord>       ReceivedMessages;
+00155 
+00156 protected:
+00157 
+00159         bool    loadNext( TMessageRecord& record );
+00160 
+00162         bool    getNext( TMessageRecord& record, sint64 updatecounter );
+00163 
+00164 private:
+00165 
+00166         // Input/output file
+00167         std::fstream                                                            _File;
+00168 
+00169         // Filename
+00170         std::string                                                                     _Filename;
+00171 
+00172         // Preloaded records
+00173         std::deque<TMessageRecord>                                      _PreloadedRecords;
+00174 
+00175         // Connection attempts
+00176         std::deque<TMessageRecord>                                      _ConnectionAttempts;
+00177 
+00178         // If true, record all events including sends
+00179         bool                                                                            _RecordAll;
+00180 };
+00181 
+00182 
+00183 } // NLNET
+00184 
+00185 
+00186 #endif // NL_MESSAGE_RECORDER_H
+00187 
+00188 /* End of message_recorder.h */
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1