--
You received this message because you are subscribed to the Google Groups "CommandFusion Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to commandfusio...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
--
--
--
There are some other issues also relating to just when you want to process the guide data. That processing needs to be done out of the anonymous function when all the replies have been received. I suggest you count each reply as it comes in and when all the replies are in ( the counter will be 1 less than the number of items in the channel list when all replies have been processed. You then process the guideData array. This is not totally safe in that you should put a timer on it so that if for some reason a reply is missed you do not hang up waiting forever for it to arrive.
From: comman...@googlegroups.com [mailto:comman...@googlegroups.com] On Behalf Of Barry Gordon
Sent: Monday, May 12, 2014 4:23 PM
To: comman...@googlegroups.com
Subject: RE: Sky+ IP control
The problem you are having is as follows:
The main outer loop that iterates the CF.request function is not doing what you want. As each CF.request is issued, and before the reply has returned, the loop process the next item in the channels array. The entire loop is completed before the first reply comes back. ergo for each reply, the processing of the body has i set to the final value of i which in your case is 44. Therefore when you build the guideData array and you pull items from the channels array you always get the same item since is i is always 44. You need to make the processing of the reply anonymous function not dependent on the value of i, just what is returned in the body since the return asynchronously with respect to the loop issuing the CF.request.
The line that needs to be fixed is:
guideData.channels.push({ name: chanData.channels[i].name, channel: chanData.channels[i].channeldec, shows: showArray
//, id: channelID, icon: channels[i].childNodes[3].attributes['src'].value
});
I suggest the following:
As soon as the body comes back and before you parse it pull out the channel number. It is in a fixed location so something like var chnNmbr=body.slice(14,18) should give the 4 character string which is the channel number. Then do a search using a quick for loop to find the index to use to find that channel name in the channels list. Use the index of where it is found to pull the name you want from the channel list
--
You received this message because you are subscribed to the Google Groups "CommandFusion Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to commandfusio...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "CommandFusion Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to commandfusio...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.