Esempio n. 1
0
        public override void Send <TMessage>(TMessage message)
        {
            EnrichMessage(message as IHaveMeta);
            var msg = LowercaseJsonSerializer.SerializeObject(message);

            byte[] toBytes = Encoding.ASCII.GetBytes(msg);
            _client.GetStream().WriteAsync(toBytes, 0, toBytes.Length);
        }
Esempio n. 2
0
 public override void Send <TMessage>(TMessage message)
 {
     if (_client == null)
     {
         throw new InvalidOperationException("Udp client is null. Did you call Connect()?");
     }
     try
     {
         EnrichMessage(message as IHaveMeta);
         var    msg     = LowercaseJsonSerializer.SerializeObject(message);
         byte[] toBytes = Encoding.ASCII.GetBytes(msg);
         _client.SendAsync(toBytes, toBytes.Length, _host, _port);
     }
     catch (Exception)
     {
         if (_throwOnConnectionError)
         {
             throw;
         }
     }
 }