예제 #1
0
        /// <summary>
        /// Sends the given <paramref name="data"/>
        /// to the <see cref="Port.ReceiveBuffer"/>
        /// of the <see cref="Port.ConnectedPort"/>.
        /// </summary>
        /// <param name="data">Data to send.</param>
        /// <returns>True if the data was successfully sent,
        /// false if not.</returns>
        public override bool Send(ITransferable data)
        {
            if (CurrentIOMode != IOMode.Output || data.GetType() != typeof(Packet) || ConnectedPort?.CurrentIOMode != IOMode.Input)
            {
                return(false);
            }

            return(ConnectedPort?.Receive(data) ?? false);
        }
예제 #2
0
        /// <summary>
        /// Receives data that has been sent to the
        /// and puts it into the <see cref="Port.ReceiveBuffer"/>.
        /// </summary>
        /// <param name="data">Data to receive.</param>
        /// <returns>True if the data was successfully received,
        /// false if not.</returns>
        public override bool Receive(ITransferable data)
        {
            if (CurrentIOMode != IOMode.Input || data.GetType() != typeof(Packet) ||
                (ReceiveBuffer != null && CurrentReceiveMode == ReceiveMode.Deny))
            {
                return(false);
            }

            ReceiveBuffer = data;
            return(true);
        }