SmartOS/TinyNet/PingMessage.h

35 lines
853 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#ifndef __PingMessage_H__
#define __PingMessage_H__
#include "Message\MessageBase.h"
#include "TokenNet\Device.h"
// 心跳消息
class PingMessage : public MessageBase
{
public:
ushort MaxSize = 0; // 可容纳的最大数据
// 初始化消息各字段为0
PingMessage();
// 从数据流中读取消息
virtual bool Read(Stream& ms);
// 把消息写入数据流中
virtual void Write(Stream& ms) const;
// 0x01 主数据
void ReadData(Stream& ms, Buffer& bs) const;
void WriteData(Stream& ms, byte code, const Buffer& bs) const;
// 0x03 硬件校验
bool ReadHardCrc(Stream& ms, const Device& dv, ushort& crc) const;
void WriteHardCrc(Stream& ms, ushort crc) const;
// 0x04 时间
bool ReadTime(Stream& ms, uint& seconds) const;
void WriteTime(Stream& ms, uint seconds) const;
};
#endif