public override async Task <dynamic> Request(SmartHomeProtocolMessage message, string hostname, int port = 9999)
        {
            var cachedMessage = _cache.FirstOrDefault(c => c.Matches(message, hostname, port));

            if (cachedMessage != null)
            {
                return(cachedMessage);
            }

            var result = await message.Execute(hostname, port);

            _cache.Add(new MessageCacheItem(result, hostname, port));
            return(result);
        }
Exemplo n.º 2
0
        public override async Task <JsonElement> Request(SmartHomeProtocolMessage message, string hostname, int port)
        {
            var cachedMessage = _cache.FirstOrDefault(c => c.Matches(message, hostname, port));

            if (cachedMessage != null)
            {
                if (cachedMessage.IsExpired(TimeGateResetSeconds))
                {
                    _cache.Remove(cachedMessage);
                }
                else
                {
                    return(cachedMessage.MessageResult);
                }
            }

            var result = await message.Execute(hostname, port);

            _cache.Add(new MessageCacheItem(result, hostname, port));
            return(result);
        }
 public override async Task <JsonElement> Request(SmartHomeProtocolMessage message, string hostname, int port = 9999)
 {
     return(await message.Execute(hostname, port));
 }
 public override async Task <dynamic> Request(SmartHomeProtocolMessage message, string hostname, int port = 9999)
 {
     return(await message.Execute(hostname, port).ConfigureAwait(false));
 }