/// <summary> /// Sends a message async to this node /// </summary> public async Task SendMessageAsync(Message msg) { using (UdpClient client = new UdpClient()) { client.Connect(IpEndpoint); byte[] data = MessageSerializer.Serialze(msg); await client.SendAsync(data, data.Length); } }
private void SendMessageTo(String messageText, Message msg, IPEndPoint node) { if (this.localEndpoint.Equals(node)) { throw new InvalidOperationException("Sendmessage: Endpoints are equal!"); } using (UdpClient client = new UdpClient()) { client.Connect(node); byte[] data = MessageSerializer.Serialze(msg); client.Send(data, data.Length); Console.WriteLine($"Message ({messageText}) sent to {node}"); } }