SmartOS/TokenNet/HelloMessage.h

46 lines
1.1 KiB
C++
Raw Permalink 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 __HelloMessage_H__
#define __HelloMessage_H__
#include "Message\MessageBase.h"
#include "Net\NetUri.h"
// 握手消息
// 请求2版本 + S类型 + S名称 + 8本地时间 + 6本地IP端口 + S支持加密算法列表
// 响应2版本 + S类型 + S名称 + 8本地时间 + 6对方IP端口 + 1加密算法 + N密钥
// 错误0xFE/0xFD + 1协议 + S服务器 + 2端口
class HelloMessage : public MessageBase
{
public:
ushort Version; // 版本
String Type; // 类型
String Name; // 名称
UInt64 LocalTime; // 时间ms
IPEndPoint EndPoint;
String Cipher;
ByteArray Key; // 密钥
byte ErrCode; // 错误码
String ErrMsg; // 错误信息
byte Protocol; // 协议,17为UDP 6为TCP
NetUri Uri;
String Cookie; //访问令牌
// 初始化消息各字段为0
HelloMessage();
HelloMessage(const HelloMessage& msg);
// 从数据流中读取消息
virtual bool Read(Stream& ms);
// 把消息写入数据流中
virtual void Write(Stream& ms) const;
// 显示消息内容
#if DEBUG
virtual String& ToStr(String& str) const;
#endif
};
#endif