public void Test() { AtomicMessageListener listener = new AtomicMessageListener(1234); listener.OnReceive += this.OnReceiveHandler; AtomicMessageSender sender = new AtomicMessageSender(new Peer("127.0.0.1", 1234)); byte[] message = { 1, 2, 43, 23 }; this.lastData = message; this.lastPeerFrom = new Peer("127.0.0.1", -1); this.received = false; sender.SendBytes(message); Thread.Sleep(3); }
/// <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 }