示例#1
0
 public static LoggerHost GetLoggerHost(SentinelHost sentinelHost, HomeConnectionServer homeConnectionServer)
 {
     lock (padlock)
     {
         return(new LoggerHost(sentinelHost, homeConnectionServer));
     }
 }
示例#2
0
        private LoggerHost(SentinelHost sentinelHost, HomeConnectionServer homeConnectionServer)
        {
            _sentinelHost         = sentinelHost;
            _homeConnectionServer = homeConnectionServer;

            LogManager.Configuration = CreateLoggingConfiguration();
        }
        public async Task <bool> UnSubscribe(string sentinelHost, string packageHost, string stateValueName)
        {
            using (var client = new HomeConnectionClient(HomeHubConnection))
            {
                var stateValueKey = new StateValueKey(sentinelHost, packageHost, stateValueName);
                if (_subscriptionsStore.ContainsKey(stateValueKey))
                {
                    var isSubscriptionDeleted = await client.Delete <bool>("subscription",
                                                                           $"{SentinelHost.GetName()}.{_subscriptionsStore[stateValueKey].Key}");

                    if (isSubscriptionDeleted)
                    {
                        RemoveSubscriptionToStore(stateValueKey);
                        await UnSubscribeOnValueChanged(new StateValueKey(sentinelHost, packageHost, stateValueName));
                    }
                    return(isSubscriptionDeleted);
                }
            }
            return(false);
        }
示例#4
0
 public StatesValuesHost(SentinelHost sentinelHost, HomeConnectionServer homeConnectionServer)
     : base(sentinelHost, homeConnectionServer)
 {
     _sentinelHost = sentinelHost;
 }
        public async Task <SubscriptionOnStateValue> Subscribe(string sentinelHost, string packageHost, string stateValueName)
        {
            using (var client = new HomeConnectionClient(HomeHubConnection))
            {
                var stateValueKey = new StateValueKey(sentinelHost, packageHost, stateValueName);
                await SubscribeOnValueChanged(stateValueKey);

                var subscriptionKeyValue = await client.PostAsJson <string>("subscription",
                                                                            new Subscription(SentinelHost.GetName(), sentinelHost, packageHost, stateValueName));

                if (!string.IsNullOrEmpty(subscriptionKeyValue))
                {
                    var subscriptionKey = new SubscriptionKey(subscriptionKeyValue);
                    if (subscriptionKey.IsValid())
                    {
                        var subscriptionOnStateValue = new SubscriptionOnStateValue(subscriptionKey, stateValueKey);
                        AddSubscriptionInStore(stateValueKey, subscriptionOnStateValue);

                        return(subscriptionOnStateValue);
                    }
                }
                else
                {
                    await UnSubscribeOnValueChanged(new StateValueKey(sentinelHost, packageHost, stateValueName));
                }
            }

            return(null);
        }
 public SubscriptionHost(SentinelHost sentinelHost, HomeConnectionServer homeConnectionServer) : base(
         sentinelHost, homeConnectionServer)
 {
     InitiateSubscriptionHubConnection();
 }