1 (edited by Xavion 2011-12-31 14:53:02)

Topic: SharedObject functionality possibly doesn't work on the chumby classic

My new weather application will only be probing XML feeds for updated data every fifteen minutes.  This is because some of the weather providers threaten to block IP addresses that make too many requests.

For this reason, I've decided to cache the downloaded XML weather data locally between sessions.  Doing so remotely would cause more of a delay each time the application is reloaded on my chumby classic.

I don't care if the data is lost when the chumby loses power.  For these reasons, the 'SharedObject' functionality looks to be the ideal solution.  The following code works in Flash Player 8, but not on my chumby.

I've removed this code fragment to avoid any confusion.  I fixed the two problems and reposted the correct code below.

When I run this in Flash Player 8, I only see "Updating online weather data ..." the first time or when the minutes are divisible by fifteen.  I realise the last part of this isn't ideal, but it'll do for now.

When I run this code on my chumby classic, I always see "Updating online weather data ...".  I know SharedObject is saving the data locally, as it exists in a subdirectory below "/tmp/pdata/" afterwards.

This means that it's the retrieval side of SharedObject that's failing on my chumby.  BTW, I never see "Made it into soInitHandler" in Flash Player 8 nor on my chumby.  The application was written in ActionScript v2.

Is there something else I need to be doing in order to get this code working on my chumby classic?  If it's an internal chumby bug, how long will it take to fix?  Is there another way that I can cache the data locally?

Re: SharedObject functionality possibly doesn't work on the chumby classic

I think SharedObject on the chumby is synchronous - the data should be there immediately after the "getLocal" call.

I just wrote an app using SharedObject and it worked for me.

Re: SharedObject functionality possibly doesn't work on the chumby classic

As mentioned above, I've fixed the problems with the earlier code fragment.  My understanding is that the 'SharedObject' loading process is handled synchronously in Flash but asynchronously in Flash Lite.

As can be seen in the following section of code, the cached data is immediately available after it's loaded in Flash.  In the case of Flash Lite, it only becomes available once the 'soInitHandler' function is triggered.

var SOName = _root._chumby_widget_instance_id;
SharedObject.addListener(SOName, soInitHandler);
Cache = SharedObject.getLocal(SOName);

// Cache has finished loading in Flash

function soInitHandler(Cache:SharedObject)
{
    // Cache has finished loading in Flash Lite
}

Re: SharedObject functionality possibly doesn't work on the chumby classic

So is the SO confirmed working on Classic and C1?  My tests are not sticking on those devices, so I wanted to double check before digging deeper.

-dev

Re: SharedObject functionality possibly doesn't work on the chumby classic

Well, they won't survive a reboot - the SharedObjects are stored in /tmp, which is RAM.

Chumby-authored widgets tend to use SharedObject only to cache small amounts of data that can be reloaded on demand from servers if it's not there.

For instance, the NOAA weather widget only stores the user-supplied zipcode in the widget parameters.  At runtime, it uses that zipcode to call a web service to map to a NOAA station, and caches that information in Shared Objects.  It then goes to NOAA's web service to fetch the current conditions and forecast data, and stores that in the Shared Objects as well.  The next time the widget is launched it checks for the presence of that data, and whether it's sufficiently current - if not, it reloads from the servers, and stores them again.  If the device is rebooted, the first time the widget launches, it will fetch the data again.

Some of the widgets stored scroll position, last photo showed, etc in Shared Objects, nothing that's critical that must survive in the long term.  That stuff should be stored on a server.

Re: SharedObject functionality possibly doesn't work on the chumby classic

SharedObjects work correctly on all chumby editions that I've tested (classic, Android, 8).  If you're having trouble loading the saved data, endeavour to pay careful attention to my last post.