public void Add(Message message)
        {
            if (_tunerDataHelper != null)
            {
                // TVHeadend don't send the information we need
                // _tunerDataHelper.addTunerInfo(message);
            }

            lock (_data)
            {
                try
                {
                    int channelID = message.getInt("channelId");
                    if (_data.ContainsKey(channelID))
                    {
                        Message storedMessage = _data[channelID];
                        if (storedMessage != null)
                        {
                            foreach (KeyValuePair<string, object> entry in message)
                            {
                                if (storedMessage.containsField(entry.Key))
                                {
                                    storedMessage.removeField(entry.Key);
                                }
                                storedMessage.putField(entry.Key, entry.Value);
                            }
                        }
                        else
                        {
                            _logger.Error("[TVHclient] ChannelDataHelper: update for channelID '" + channelID + "' but no initial data found!");
                        }
                    }
                    else
                    {
                        if (message.containsField("channelNumber") && message.getInt("channelNumber") > 0) // use only channels with number > 0
                        {
                            _data.Add(channelID, message);
                        }
                    }
                }
                catch (Exception ex)
                {
                    _logger.Error("[TVHclient] ChannelDataHelper.Add caught exception: " + ex.Message + "\nMessage=" + message);
                }
            }
        }
Esempio n. 2
0
 public void addTunerInfo(Message tunerMessage)
 {
     lock (_data)
     {
         string channelID = "" + tunerMessage.getInt("channelId");
         if (_data.ContainsKey(channelID))
         {
             _data.Remove(channelID);
         }
         _data.Add(channelID, tunerMessage);
     }
 }