コード例 #1
0
        public static ChannelInfo ParseRawChannelData(JsonObject channelRawData)
        {
            string channelName = null;
            string channelId = null;
            var minorNumber = 0;
            var majorNumber = 0;

            var channelInfo = new ChannelInfo {RawData = channelRawData};

            try
            {
                if (!channelRawData.ContainsKey("channelName"))
                    channelName = channelRawData.GetNamedString("channelName");

                if (!channelRawData.ContainsKey("channelId"))
                    channelId = channelRawData.GetNamedString("channelId");

                if (!channelRawData.ContainsKey("majorNumber"))
                    majorNumber = (int)channelRawData.GetNamedNumber("majorNumber");

                if (!channelRawData.ContainsKey("minorNumber"))
                    minorNumber = (int)channelRawData.GetNamedNumber("minorNumber");

                var channelNumber = !channelRawData.ContainsKey("channelNumber")
                    ? channelRawData.GetNamedString("channelNumber")
                    : string.Format("{0}-{1}", majorNumber, minorNumber);

                channelInfo.Name = channelName;
                channelInfo.Id = channelId;
                channelInfo.Number = channelNumber;
                channelInfo.MajorNumber = majorNumber;
                channelInfo.MinorNumber = minorNumber;

            }
            catch (Exception e)
            {
                //TODO: get some analysis here
                throw new Exception("There was an error parsin the channel information", e);
            }

            return channelInfo;
        }
コード例 #2
0
        public void SetChannel(ChannelInfo channelInfo, ResponseListener listener)
        {
            var responseListener = new ResponseListener
            (
                loadEventArg =>
                {
                    //((ConnectSdk.Windows.Service.Capability.Listeners.LoadEventArgs)(o)).Load.payload

                    var loa = loadEventArg as LoadEventArgs;
                    if (loa != null)
                    {
                        var channelList = loa.Load.GetPayload() as List<ChannelInfo>;
                        if (channelList != null)
                        {
                            var requestUrl = GetUdapRequestUrl(UdapPathCommand);

                            var ps = new Dictionary<string, string>();

                            foreach (var ch in channelList)
                            {
                                //var rawData = ch.RawData;

                                var major = channelInfo.MajorNumber;
                                var minor = channelInfo.MinorNumber;

                                var majorNumber = ch.MajorNumber;
                                var minorNumber = ch.MinorNumber;

                                if (major != majorNumber || minor != minorNumber) continue;
                                ps.Add("name", "HandleChannelChange");
                                ps.Add("major", major.ToString());
                                ps.Add("minor", minor.ToString());

                                break;
                            }
                            var httpMessage = GetUdapMessageBody(UdapApiCommand, ps);

                            var request = new ServiceCommand(this, requestUrl, httpMessage, listener);
                            request.Send();
                        }
                        else
                        {
                            Util.PostError(listener, new ServiceCommandError(500, "Could not retrieve channel list"));
                        }
                    }
                    else
                    {
                        Util.PostError(listener, new ServiceCommandError(500, "Could not retrieve channel list"));
                    }
                },
                serviceCommandError => Util.PostError(listener, serviceCommandError)
            );

            GetChannelList(responseListener);
        }
コード例 #3
0
        private ChannelInfo ParseRawChannelData(JsonObject channelRawData)
        {
            string channelName = null;
            string channelId = null;

            var channelInfo = new ChannelInfo();
            channelInfo.RawData = channelRawData;

            try
            {
                if (channelRawData.ContainsKey("channelName"))
                    channelName = channelRawData.GetNamedString("channelName","");

                if (channelRawData.ContainsKey("channelId"))
                    channelId = channelRawData.GetNamedString("channelId", "");

                string channelNumber = channelRawData.GetNamedString("channelNumber", "");

                int majorNumber;
                if (channelRawData.ContainsKey("majorNumber"))
                    majorNumber = (int)channelRawData.GetNamedNumber("majorNumber");
                else
                    majorNumber = ParseMajorNumber(channelNumber);

                int minorNumber;
                if (channelRawData.ContainsKey("minorNumber"))
                    minorNumber = (int)channelRawData.GetNamedNumber("minorNumber");
                else
                    minorNumber = ParseMinorNumber(channelNumber);

                channelInfo.Name = channelName;
                channelInfo.Id = channelId;
                channelInfo.Number = channelNumber;
                channelInfo.MajorNumber = majorNumber;
                channelInfo.MinorNumber = minorNumber;

            }
            catch (Exception e)
            {
                throw e;
            }

            return channelInfo;
        }
コード例 #4
0
        public void SetChannel(ChannelInfo channelInfo, ResponseListener listener)
        {
            const string uri = "ssap://tv/openChannel";
            var payload = new JsonObject();

            try
            {
                payload.Add("channelNumber", JsonValue.CreateStringValue(channelInfo.Number));
            }
            catch (Exception)
            {

            }

            var request = new ServiceCommand(this, uri, payload, listener);
            request.Send();
        }
コード例 #5
0
 public ProgramList(ChannelInfo channel, JsonArray programList)
 {
     Channel = channel;
     ProgramsList = programList;
 }
 private void ChangeChannel(ChannelInfo channelInfo)
 {
     tvControl.SetChannel(channelInfo, null);
 }
コード例 #7
0
 /// <summary>
 /// Compares two ChannelInfo objects.
 /// </summary>
 /// <param name="other">ChannelInfo object to compare.</param>
 /// <returns>YES if both ChannelInfo number & name values are equal</returns>
 protected bool Equals(ChannelInfo other)
 {
     return string.Equals(Name, other.Name) && string.Equals(Id, other.Id) && string.Equals(Number, other.Number) && MinorNumber == other.MinorNumber && MajorNumber == other.MajorNumber && Equals(RawData, other.RawData);
 }