public GetServiceHandler(ICommandDispatcher Dispatcher, ILogger Logger)
        {
            Dispatcher.IsNotNull($"Invalid parameter received in the {nameof(GetServiceHandler)} constructor. {nameof(Dispatcher)}");
            Contracts.IsTrue(Dispatcher is ServicePublisher, $"Expected a {nameof(XFS4IoTServer.ServicePublisher)} got {Dispatcher.GetType().FullName}");
            Logger.IsNotNull($"Invalid parameter received in the {nameof(GetServiceHandler)} constructor. {nameof(Logger)}");

            this.ServicePublisher = (ServicePublisher)Dispatcher;
            this.Logger           = Logger;
        }
Beispiel #2
0
        public EndPoint(Uri EndPointUri,
                        IMessageDecoder CommandDecoder,
                        ICommandDispatcher CommandDispatcher,
                        ILogger Logger)
        {
            EndPointUri.IsNotNull($"Invalid parameter received in the {nameof(EndPoint)} constructor. {nameof(EndPointUri)}");
            CommandDecoder.IsNotNull($"Invalid parameter received in the {nameof(EndPoint)} constructor. {nameof(CommandDecoder)}");
            CommandDispatcher.IsNotNull($"Invalid parameter received in the {nameof(EndPoint)} constructor. {nameof(CommandDispatcher)}");
            Logger.IsNotNull($"Invalid parameter received in the {nameof(EndPoint)} constructor. {nameof(Logger)}");

            this.CommandDecoder    = CommandDecoder;
            this.CommandDispatcher = CommandDispatcher;
            this.Logger            = Logger;

            HttpListener = new HttpListener()
            {
                IgnoreWriteExceptions = false,
                Prefixes = { EndPointUri.ToString() },
            };

            HttpListener.Start();

            Logger.Log(Constants.Component, $"New endpoint at {EndPointUri.ToString()}");
        }