public static TcpSender Initialize(string hostname, int port, TcpSenderSettings senderSets) { var sink = new TcpSink(hostname, port, TimeSpan.FromSeconds(senderSets.WriteTimeoutSec), TimeSpan.FromSeconds(senderSets.ConnectTimeoutSec)); var queue = new RingBuffer <byte[]>(senderSets.QueueSize); var sender = new TcpSender(sink, queue, TimeSpan.FromSeconds(senderSets.ReconnectPeriodSec)) { _stream = sink.TryInitializeStream() }; if (sender._stream == null) { sender.ScheduleReconnect(); } return(sender); }
private TcpSender(TcpSink sink, RingBuffer <byte[]> queue, TimeSpan reconnectPeriod) { _sink = sink; _queue = queue; _reconnectPeriod = reconnectPeriod; }