/// ///<summary>Add a channel to prepared IChabu instance.</summary> /// /// <param name="channelId"> must be given in correct sequence, starting with zero for the first /// channel. This is redundant, but helps to avoid wrong use.</param> /// <param name="priority"> gives the priority for xmit data. Channels with the same priority will send /// in a round robin. The channel with the lower priority number is handled /// first.</param> /// <param name="recvTarget">The adapter to pass the received data</param> /// <param name="xmitSource">The adapter to pass the data to xmit</param> /// <returns>this ChabuBuilder instance. Use for fluent API style.</returns> /// public ChabuBuilder AddChannel(int channelId, int priority, ChabuRecvByteTarget recvTarget, ChabuXmitByteSource xmitSource) { Utils.ensure(channelId == this.nextChannelId, ChabuErrorCode.CONFIGURATION_CH_ID, "Channel ID must be ascending, expected {0}, but was {1}", this.nextChannelId, channelId); var channel = new ChabuChannelImpl(priority, recvTarget, xmitSource); _channels.add(channel); this.nextChannelId++; return(this); }
public ChabuChannelImpl(int priority, ChabuRecvByteTarget recvTarget, ChabuXmitByteSource xmitSource) { this.recvTarget = recvTarget; this.xmitSource = xmitSource; Utils.ensure(priority >= 0, ChabuErrorCode.CONFIGURATION_CH_PRIO, "priority must be >= 0, but is {0}", priority); Utils.ensure(recvTarget != null, ChabuErrorCode.CONFIGURATION_CH_USER, "IChabuChannelUser must be non null"); Utils.ensure(xmitSource != null, ChabuErrorCode.CONFIGURATION_CH_USER, "IChabuChannelUser must be non null"); this.recvArmShouldBeXmit = true; this.priority = priority; }