Ejemplo n.º 1
0
 public void Send(Metric metric)
 {
     var datagram = new Dgram(DatagramSize);
     if(!datagram.TryAppend(metric, Encoding))
         throw new ArgumentException();
     datagram.SendTo(socket, target);
 }
Ejemplo n.º 2
0
 public void Send(IEnumerable<Metric> metrics)
 {
     var datagram = new Dgram(DatagramSize);
     foreach(var item in metrics) {
         var start = datagram.Position;
         if(!datagram.TryAppend(item, Encoding) || datagram.Capacity < 1) {
             datagram.SendTo(socket, target, start);
             datagram.Clear();
             if(!datagram.TryAppend(item, Encoding))
                 throw new ArgumentException();
         }
         datagram.Append(RecordSeparator);
     }
     datagram.SendTo(socket, target);
 }