Ejemplo n.º 1
0
        public void Listen(CancellationToken cancellationToken)
        {
            if (!_preemptOnPort.HasValue)
            {
                return;
            }

            var localEndPoint = new IPEndPoint(IPAddress.Any, _preemptOnPort.Value);

            _server = new UdpServer();
            _server.Start(localEndPoint, cancellationToken);

            _server.ReceiveError    += (s, e) => _logger.Info(LogTag, "Socket error {0} during {1}.", e.ErrorCode, e.LastOperation);
            _server.MessageReceived += (s, e) => Preempt(e);

            _logger.Info(LogTag, "Preempt poll udp listener configured on port {0}.", _preemptOnPort.Value);
        }
Ejemplo n.º 2
0
        public void Listen(CancellationToken cancellationToken)
        {
            if (!_preemptOnPort.HasValue)
            {
                return;
            }

            var localEndPoint = new IPEndPoint(IPAddress.Any, _preemptOnPort.Value);

            _server = new UdpServer();
            _server.Start(localEndPoint, cancellationToken);

            _server.ReceiveError += (s, e) => _logger.Info(LogTag, "Socket error {0} during {1}.", e.ErrorCode, e.LastOperation);
            _server.MessageReceived += (s, e) => Preempt(e);

            _logger.Info(LogTag, "Preempt poll udp listener configured on port {0}.", _preemptOnPort.Value);
        }
Ejemplo n.º 3
0
        private void ConfigureUdp()
        {
            if (!_preemptOnPort.HasValue)
                return;

            var localEndPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), _preemptOnPort.Value);

            _server = new UdpServer();
            _server.Start(localEndPoint, _tokenSource.Token);

            _server.ReceiveError += (s, e) => _logger.Info(LogTag, "Socket error {0} during {1}.", e.ErrorCode, e.LastOperation);
            _server.MessageReceived += (s, e) =>
                                           {
                                               if (ShouldPreempt(e.Message))
                                                   _preemptIntervalEvent.Set();
                                           };
        }