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); }
public void Send(Metric metric) { var datagram = new Dgram(DatagramSize); if(!datagram.TryAppend(metric, Encoding)) throw new ArgumentException(); datagram.SendTo(socket, target); }