Exemplo n.º 1
0
    public void SetCmdType(NetCmdType nct)
    {
        int cmd = (int)nct;

        CmdType    = (byte)(cmd >> 8);
        SubCmdType = (byte)cmd;
    }
Exemplo n.º 2
0
        public PackageIn msg;      // 数据buff

        public NetCommand()
        {
            this.dwType = NetCmdType.NetCmd_Null;
            this.dwLen  = 0;
            this.error  = NetWorkError.NetWorkError_null;
            msg         = null;
        }
Exemplo n.º 3
0
 public NetCommand(NetCommand cmd)
 {
     this.dwType = cmd.dwType;
     this.dwLen  = cmd.dwLen;
     if (this.dwLen > 0)
     {
         this.msg = cmd.msg;
     }
 }
Exemplo n.º 4
0
 public static bool CheckCmdType(NetCmdType cmdType)
 {
     if (NetCmdMapping.IsRegisterCmd(cmdType))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemplo n.º 5
0
    public static NetTypeInfo GetTypeInfo(NetCmdType type)
    {
        ushort      size = (ushort)TypeSize <T> .SIZE;
        NetTypeInfo nti  = new NetTypeInfo();

        nti.CmdType      = type;
        nti.StructType   = TypeSize <T> .RUN_TYPE;
        nti.StructSize   = size;
        nti.TypeHashCode = TypeSize <T> .HASH;
        return(nti);
    }
Exemplo n.º 6
0
    public static NetCmdBase ByteToCmd(byte[] byteData, int offset, int length)
    {
        if (length < 4)
        {
            return(null);
        }
        int t1 = (int)byteData[offset + 3];
        int t2 = (int)byteData[offset + 2];

        t1 = t1 << 8 | t2;

        NetCmdType cmdType = (NetCmdType)(t1);

        if (cmdType >= NetCmdType.CMD_MAX)
        {
            return(null);
        }
        NetTypeInfo typeInfo = NetCmdMapping.GetTypeInfo(cmdType);

        if (typeInfo == null)
        {
            LogMgr.Log("未注册的命令:" + cmdType.ToString());
            return(null);
        }
        if (length < typeInfo.StructSize)
        {
            LogMgr.Log("命令大小与结构体大小不匹配:" + length.ToString() + " : " + typeInfo.StructSize.ToString() + " :" + cmdType.ToString());
            return(null);
        }
        NetCmdBase cmd = (NetCmdBase)TypeReflector.BytesToObj(
            typeInfo.TypeHashCode,
            byteData,
            offset,
            length
            );

        return(cmd);
    }
Exemplo n.º 7
0
 protected virtual void _RegisterEvent(NetCmdType aEventName_cmd, EventDelegate aEventDelegate)
 {
     msgList[aEventName_cmd + ""] = aEventDelegate;
     NetManager.Instance.AddNetEventListener(aEventName_cmd, aEventDelegate);
 }
Exemplo n.º 8
0
 public NetCmd(NetCmdType t)
 {
     SetCmdType(t);
 }
Exemplo n.º 9
0
 public bool AddNetEventListener(NetCmdType aEventName_cmd, EventDelegate aEventDelegate)
 {
     return(AddEventListener(aEventName_cmd + "", aEventDelegate));
 }