/// <summary> /// 单方向信道抽象父类,提供了相关的基本操作 /// </summary> /// <param name="channel">基于流的通讯信道</param> /// <param name="protocolStack">协议栈</param> protected OnewayChannel(IRawTransportChannel channel, IProtocolStack protocolStack) { if (channel == null) { throw new ArgumentNullException(nameof(channel)); } if (!channel.IsConnected) { throw new ArgumentException("Current raw transport channel hsa been disconnected!"); } if (protocolStack == null) { throw new ArgumentNullException(nameof(protocolStack)); } if (!protocolStack.Initialize()) { throw new ArgumentException("Cannot initialize current protocol stack!"); } _channel = channel; if (_channel.Buffer == null) { _channel.Buffer = new ReceiveBuffer(102400); } _logicalAddress = _channel.LogicalAddress; _address = _channel.Address; _channel.Disconnected += RawChannelDisconnected; _channel.ReceivedData += RawChannelReceivedData; _protocolStack = protocolStack; }
/// <summary> /// 单方向信道抽象父类,提供了相关的基本操作 /// </summary> /// <param name="protocolStack">协议栈</param> protected OnewayChannel(IProtocolStack protocolStack) { if (protocolStack == null) { throw new ArgumentNullException(nameof(protocolStack)); } if (!protocolStack.Initialize()) { throw new ArgumentException("Cannot initialize current protocol stack!"); } _protocolStack = protocolStack; }