public async void SendMessage(DiscoveryMessage discoveryMessage) { byte[] message; try { if (_logger.IsTrace) { _logger.Trace($"Sending message: {discoveryMessage}"); } message = Serialize(discoveryMessage); } catch (Exception e) { _logger.Error($"Error during serialization of the message: {discoveryMessage}", e); return; } IAddressedEnvelope <IByteBuffer> packet = new DatagramPacket(Unpooled.CopiedBuffer(message), discoveryMessage.FarAddress); // _logger.Info($"The message {discoveryMessage} will be sent to {_channel.RemoteAddress}"); await _channel.WriteAndFlushAsync(packet).ContinueWith(t => { if (t.IsFaulted) { if (_logger.IsTrace) { _logger.Trace($"Error when sending a discovery message Msg: {discoveryMessage.ToString()} ,Exp: {t.Exception}"); } } }); }
public void ToStringTest() { DiscoveryMessage target = new DiscoveryMessage(); string actual = target.ToString(); Assert.IsFalse(actual.Length == 0); Assert.IsTrue(actual.StartsWith("{"), "Didn't start with '{'"); Assert.IsTrue(actual.EndsWith("}"), "Didn't end with '}'"); }