示例#1
0
        /// <summary>
        /// Sends a message to peer.
        /// </summary>
        /// <param name="peer">The peer.</param>
        /// <param name="message">The message.</param>
        /// <param name="onCompleteHandler">On complete handler.</param>
        private static void SendMessage(Peer peer, ProtocolMessage message, AtomicMessageSender.OnCompleteHandler onCompleteHandler = null)
        {
            if (peer == null)
            {
                return;
            }

            AtomicMessageSender sender = new Network.AtomicMessageSender(peer);

            if (onCompleteHandler != null)
            {
                sender.OnComplete += onCompleteHandler;
            }

            byte[] bytesMessage = new ProtocolMessageContainer(message).SerializeAsBytes();
            sender.SendBytes(bytesMessage);

            // TODO on error
        }
        /// <summary>
        /// Sends a message to peer.
        /// </summary>
        /// <param name="peer">The peer.</param>
        /// <param name="message">The message.</param>
        /// <param name="onCompleteHandler">On complete handler.</param>
        private static void SendMessage(Peer peer, ProtocolMessage message, AtomicMessageSender.OnCompleteHandler onCompleteHandler = null)
        {
            if (peer == null)
            {
                return;
            }

            AtomicMessageSender sender = new Network.AtomicMessageSender(peer);
            if (onCompleteHandler != null)
            {
                sender.OnComplete += onCompleteHandler;
            }

            byte[] bytesMessage = new ProtocolMessageContainer(message).SerializeAsBytes();
            sender.SendBytes(bytesMessage);

            // TODO on error
        }