/// <summary> /// 发送协议,通过传入需要使用的协议内容和输入结构 /// </summary> /// <param name="unit"></param> /// <param name="content"></param> /// <returns></returns> public virtual OutputStruct SendReceive(ProtocalUnit unit, InputStruct content) { int t = 0; //如果为特别处理协议的话,跳过协议扩展收缩 var formatContent = unit.Format(content); if (formatContent != null) { byte[] receiveContent; if (unit is SpecialProtocalUnit) { receiveContent = ProtocalLinker.SendReceiveWithoutExtAndDec(formatContent); } else { receiveContent = ProtocalLinker.SendReceive(formatContent); } if (receiveContent != null) { return unit.Unformat(receiveContent, ref t); } } return null; }
protected void Register(ProtocalUnit linkProtocal) { if (linkProtocal == null) return; Protocals.Add(linkProtocal.GetType().FullName, linkProtocal); }