private static void DOWork()
{
while (KeepGoing)
{
// OK user requested that we terminate
// recording, so lets do it
if (RequestStop == true)
KeepGoing = false;
else
{
try
{
// Lets receive data in an array of bytes
// (an octet, of course composed of 8bits)
UDPBuffer = rcv_sock.Receive(ref rcv_iep);
BytesProcessed = BytesProcessed + UDPBuffer.Length;
if (RecordingEnabled == true)
{
if (ReplayFormatRequested == true)
{
TimeSpan TimeDiff = DateTime.Now - LastDataBlockDateTime;
LastDataBlockDateTime = DateTime.Now;
// Header 1: Size of the original data block
// Header 2: The time between two data blocks (current and the last one)
//-----------------------------------------------------------------------
// Header 1 // Header 2
// ----------------------------------------------------------------------
// 4 bytes // 4 bytes
// First add the size of the data block, not including the two headers
// Block size
RecordingBinaryWriter.Write(UDPBuffer.Length);
// Time between last and this block
RecordingBinaryWriter.Write(TimeDiff.Milliseconds);
// Now write the data block
RecordingBinaryWriter.Write(UDPBuffer);
}
else
{
RecordingBinaryWriter.Write(UDPBuffer);
}
}
// If forwarding enable then forward
// the data as soon as it is recived
if (ForwardingEnabled == true)
{
tx_sock.Send(UDPBuffer, UDPBuffer.Length, tx_iep);
}
}
catch
{
}
}
}
Cleanup();
}