Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
 private TcpSender(TcpSink sink, RingBuffer <byte[]> queue, TimeSpan reconnectPeriod)
 {
     _sink            = sink;
     _queue           = queue;
     _reconnectPeriod = reconnectPeriod;
 }