1. Message类(对消息id枚举及自定义内容的字节数组的封装)
public class Message
{
public ushort _cmdTag;
public byte[] _data;
public Message(ushort cmd_no, byte[] cmd)
{
_cmdTag = cmd_no;
_data = cmd;
}
}
2.CmdParser类(用于注册(消息id--解析函数)到字典中,并每帧从消息队列中取出服务器发来的进行解析)
using System;
using System.Collections.Generic;
class CmdParser
{
public delegate bool ParseCommand(Message message);
public Dictionary<int, ParseCommand> m_parser;
public static CmdParser _instance = null;
public st