private IBPlaybackMessage ReadLogMetaData() { IBPlaybackMessage msg = (IBPlaybackMessage)_reader.ReadUInt32(); _lastTimeStamp = _nextTimeStamp; _nextTimeStamp = DateTime.FromBinary(_reader.ReadInt64()); _lastMsgSize = _reader.ReadInt32(); _position = _logStream.Position; return(msg); }
private void HandlePlaybackMetaData(IBPlaybackMessage msg) { // Now that we know the previous message size, seek to the size position // in the stream and write the position into the stream, and seek back to // where we currently are if (_lastEmptySize != 0) { long position = _recordStream.Position; _recordStream.Seek(_lastEmptySize, SeekOrigin.Begin); // Write the newly calculated size of the previous message as uint (32-bit) _recordWriter.Write((uint)(position - _lastEmptySize - sizeof(uint))); _recordStream.Seek(position, SeekOrigin.Begin); } // Write that there was a request, specify 0 for size for now (next message will adjust this) _recordWriter.Write((uint)msg); // Write the time stamp _recordWriter.Write(DateTime.Now.ToBinary()); _lastEmptySize = _recordStream.Position; // Write the temporary message size as a uint (32-bit) size _recordWriter.Write((uint)0); }
private void ProcessPlaybackStream() { while (_doWork) { IBPlaybackMessage msg = ReadLogMetaData(); switch (msg) { case IBPlaybackMessage.Receive: // Read a single message processing it ProcessSingleMessage(); break; case IBPlaybackMessage.Send: // Send the server message to our dummy server, // this server will round-trip the server message and "understand" what // client side message + parameters were used when issueing the server command... _loopbackServer.ProcessSingleMessage(); break; } } }