Exemple #1
0
        public void StartListening(BusSettings settings)
        {
            if (settings.StateFor(Protocol) == TransportState.Disabled)
            {
                return;
            }

            var incoming = settings.Listeners.Where(x => x.Scheme == Protocol).ToArray();

            assertNoDuplicatePorts(incoming);

            foreach (var uri in incoming)
            {
                var agent    = new SocketListeningAgent(uri.Port, settings.Cancellation);
                var listener = uri.IsDurable()
                    ? _persistence.BuildListener(agent, _workerQueue)
                    : new LightweightListener(_workerQueue, _logger, agent);

                _listeners.Add(listener);

                listener.Start();
            }

            if (incoming.Any())
            {
                var uri  = incoming.First();
                var port = uri.Port;
                LocalReplyUri = uri.ToMachineUri();
            }
        }