Esempio n. 1
0
        //public void Allow(AllowInfo allow)
        //{
        //    if (allow == null) { return; }
        //    if (!m_Allow.ContainsKey(allow.Key))
        //    {
        //        m_Allow.Add(allow.Key, allow);
        //    }
        //    m_Allow[allow.Key] = allow;
        //}
        //public void Remove(AllowInfo allow)
        //{
        //    if (m_Allow.ContainsKey(allow.Key))
        //    {
        //        m_Allow.Remove(allow.Key);
        //    }
        //}
        private void OnValueUpdated(string channel, string item, string value)
        {
            string    key       = $"{channel}.{item}";
            AllowInfo allowinfo = null;

            //foreach (var allow in m_Allow.Values)
            foreach (var allow in m_Allow)
            {
                if (allow.isAllow(channel, item))
                {
                    allowinfo = allow;
                    break;
                }
            }
            if (allowinfo == null)
            {
                return;
            }

            if (!m_Channels.ContainsKey(key))
            {
                ChannelInfo cinfo = new ChannelInfo(Server, allowinfo.Style, allowinfo.Interval, channel, item, value);
                m_Channels.TryAdd(key, cinfo);
            }
            else
            {
                m_Channels[key].Value = value;
            }
        }
Esempio n. 2
0
 public void Remove(AllowInfo ainfo)
 {
     m_Publish.OnValueUpdated -= OnValueUpdated;
     foreach (var channel in m_Channels)
     {
         if (channel.Value.Channel == ainfo.Channel &&
             (ainfo.Item == string.Empty || channel.Value.Item == ainfo.Item))
         {
             ChannelInfo cinfo;
             m_Channels.TryRemove(channel.Key, out cinfo);
             cinfo.Dispose();
         }
     }
     m_Publish.OnValueUpdated += OnValueUpdated;
 }