public void SetCmdType(NetCmdType nct) { int cmd = (int)nct; CmdType = (byte)(cmd >> 8); SubCmdType = (byte)cmd; }
public PackageIn msg; // 数据buff public NetCommand() { this.dwType = NetCmdType.NetCmd_Null; this.dwLen = 0; this.error = NetWorkError.NetWorkError_null; msg = null; }
public NetCommand(NetCommand cmd) { this.dwType = cmd.dwType; this.dwLen = cmd.dwLen; if (this.dwLen > 0) { this.msg = cmd.msg; } }
public static bool CheckCmdType(NetCmdType cmdType) { if (NetCmdMapping.IsRegisterCmd(cmdType)) { return(true); } else { return(false); } }
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); }
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); }
protected virtual void _RegisterEvent(NetCmdType aEventName_cmd, EventDelegate aEventDelegate) { msgList[aEventName_cmd + ""] = aEventDelegate; NetManager.Instance.AddNetEventListener(aEventName_cmd, aEventDelegate); }
public NetCmd(NetCmdType t) { SetCmdType(t); }
public bool AddNetEventListener(NetCmdType aEventName_cmd, EventDelegate aEventDelegate) { return(AddEventListener(aEventName_cmd + "", aEventDelegate)); }