Hi Kathryn,
I agree with you as it looks much easier than setting another server, without saying the need to hard code Java app which will do kind of the same things as laszlo components does to retrieve data.
Anyway, i'll try those both methods, thanks for your help/advices ! I'll keep you all in touch.
AAhh, I just thought about something like :
when updating something, PHP backend will record what has been changed in a database, or why not in a xml file, whatever. Then when another client polls php backend for updates, simply looking at this file to know what to send back to.
I'm always thinking about the case where two clients are using the same app on the same server, one change something then the other would see change immediatly.
Although, When looking at Red5 sample, I though that data changes were automatically pulled out to other clients app. Take a look at the exemple program from Red 5 where you can move the Red 5 logo on an app instance and then you can see changes made immediatly to another app instance - C:\program files\Red5\swf\BallControl.swf where Red5 is my install dir of Red5 . That's wonderful :D That's my goal with database modification n_uplets- I know i repeat myself :)-
Thanks
2006/5/11, kathryn aaker <[EMAIL PROTECTED]>:
Hi Stephane,
No, neither of my solutions requires Red5; "polling" would just mean
having Laszlo call an update script through normal means (REST), to
check if there are changes. For instance, you could have a dataset like:
<dataset name="dsUpdate" src="" href="http://yourdomain.com/getUpdateStatus.php">http://yourdomain.com/getUpdateStatus.php "
type="http" request="false"/>
and the getUpdateStatus.php script could return something like:
<status doUpdate="false"/> if the server status hasn't changed, or:
<status doUpdate="true"/> if the Laszlo app needs to update
You could use an LzTimer to trigger dsUpdate to request every 30
seconds, like:
<method event="oninit">
this.updateDelegate= new LzDelegate( this, "doUpdate" );
LzTimer.addTimer( this.updateDelegate, 30000);
</method>
<method name="doUpdate">
dsUpdate.doRequest();
</method>
and then have an attribute bound to the dataset to listen for the
changed server status:
<attribute name="updatestatus" value="$path{'dsUpdate:/status/@doUpdate'}"/>
<method event="onupdatestatus" args="status">
if(status == "true")
{
// re-request the data from the server again
}
</method>
This keeps updates pretty simple, but you could make it more complex by
having the <status/> data return all the data that needs to be updated, too.
The *second* solution, the one that I'm using, requires some
ActionScript, which you can just put in a <script> tag. It will also
require that you have a socket server, but they can be very very simple.
This is essentially my code for the XMLSocket object. It's in a
<script> tag at the canvas level.
function JSSocketConnector(handler)
{
this.handler = handler;
}
JSSocketConnector.prototype = new XMLSocket();
JSSocketConnector.prototype.constructor = JSSocketConnector;
JSSocketConnector.prototype.doConnect = function(host, port)
{
this.connect(host, port);
}
JSSocketConnector.prototype.sendXML = function(xml)
{
this.send(message);
}
JSSocketConnector.prototype.>{
var data = "" ( result );
this.handler.handleSocketData(data);
}
This will create an object in global scope called "JSSocketConnector",
and I use it in Laszlo like this:
<method event="oninit">
this.socketconnector = new JSSocketConnector(this);
this.socketconnector.doConnect("192.168.1.115", 3668);
</method>
<method name="handleSocketData" args="updateData">
// inspect updateData to see what the update is
</method>
It's not supported, because you really shouldn't be writing ActionScript
in <script> tags - it won't work if you export to DHTML, for instance,
and there's no guarantee that it'll keep working in Laszlo. But it's
simple and lightweight, and I figure if it breaks later I can switch it
to method #1, or some sort of future-supported Laszlo method later.
This is the basics of how you can use either of these techniques for
getting updates from a server. Does it make sense how you could extend
it to receive specific kinds of updates? You can definitely use Red5,
but if you're just trying to get data updates, this is much simpler.
Kathryn
Stéphane . wrote:
> As i could understand, your first solution is used by Red5 (polling, and
> increasing polling interval as their is no update)
> You say you use the latter one which is not availlable (as you said) on
> openlaszlo for now. How are you doing this so ? in Flash 8 directly ? i
> dont understand this :)
> Anyway, as there is many things that can be updated (a table n_uplet, an
> editbox, and so on) Does i have to write code that handle this for every
> objects that can be updated ? If i'm not clear, just tell.
> Thanks !
>
> 2006/5/11, kathryn aaker <[EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED] >>:
>
> If you're only trying to update the client with data, you have a few
> options besides Comm Server/Red5, which may be a bit heavy-handed.
>
> Among them,
> - Have your laszlo application poll for updates, every 10 seconds or
> however long makes sense.
> - Use the (currently unsupported by Laszlo) XMLSocket object
> (ActionScript) to receive "update" events, and either have the new data
> pushed in through the socket, or use that to trigger an update through
> the normal data request channel.
>
> I'm using the latter of the two on a project now, and it's working well-
> it's light enough that I could switch to a polling method later on with
> ease.
>
>
>
> Stéphane . wrote:
> > In a old post, i've asked if it's possible to refresh data on a
> client
> > program when another client program is modifying database table
> n_uplets.
> > I've been searching trhough www.osflash.org
> <http://www.osflash.org> < http://www.osflash.org> and
> > saw Red 5 (www.osflash.org/red5 <http://www.osflash.org/red5>
> < http://www.osflash.org/red5 <http://www.osflash.org/red5>>), a flash
> > server with functions like Flex's future Adobe comms. server.
> > I think it can do that. I'll send my progress there if nobody is
> against.
> > Thanks.
>
>
_______________________________________________ Laszlo-user mailing list [email protected] http://www.openlaszlo.org/mailman/listinfo/laszlo-user
