Пример #1
0
    private static void read_echo(MrsConnection connection, byte[] payload, UInt32 payload_len)
    {
        mrs.Time read_time = new mrs.Time();
        read_time.Set();
        mrs.Buffer buffer = new mrs.Buffer();
        buffer.Write(payload, payload_len);
        while (0 < buffer.GetDataLen())
        {
            mrs.Time write_time = buffer.ReadTime();
            MRS_LOG_DEBUG("read_echo data={0} data_len={1} diff_time={2}({3} - {4})",
                          ToString(buffer.GetData()), g_WriteDataLen,
                          (read_time - write_time).ToString(), read_time.ToString(), write_time.ToString());
            if (!buffer.Read(null, g_WriteDataLen))
            {
                MRS_LOG_ERR("Lost data. len={0} {1}", buffer.GetDataLen(), mrs.Utility.ToHex(buffer.GetData(), buffer.GetDataLen()));
                break;
            }

            ++g_ReadCount;
            if (g_WriteCount * g_Connections <= g_ReadCount)
            {
                MRS_LOG_DEBUG("Since all records have been received, it is finished.");
            }
        }
    }
Пример #2
0
    private static void write_echo(MrsConnection connection, byte[] data, UInt32 data_len)
    {
        mrs.Time write_time = new mrs.Time();
        write_time.Set();
        mrs.Buffer buffer = new mrs.Buffer();
        buffer.WriteTime(write_time);
        buffer.Write(data, data_len);

        if (g_IsValidRecord)
        {
            mrs_write_record(connection, g_RecordOptions, g_paytype, buffer.GetData(), buffer.GetDataLen());
            MRS_LOG_DEBUG("WROTE RECORD type:0x{0:X}", g_paytype);
        }
        else
        {
            mrs_write(connection, buffer.GetData(), buffer.GetDataLen());
        }
    }