| Robin Southgate 2005-06-21, 5:45 pm |
| Hi,
I have an RSO that is essentially a timer on the server so that all clients can see how long is left until an event occurs. Each client has this function called by the onSync event:
public function updateTimer(val):Void {
var raceStart = val.target.data.start;
var countDownNum = val.target.data.countDown;
if (countDownNum != undefined && countDownNum != "" && countDownNum <=60) {
myStartButton.setLabel("startRace", _global.textlist.getTextMessage("Start_Race_Button") + " (" + countDownNum.toString() + ")" );
myStartButton.setLabel("startRaceShadow", _global.textlist.getTextMessage("Start_Race_Button") + " (" + countDownNum.toString() + ")" );
}
}
And on the comms server I have the following two functions that control a countdown from 60 to zero:
application.startTimer = function(client) {
application.raceStart = SharedObject.get("raceStart", false);
var myRaceStart = new Date();
application.myRaceStartMilli = myRaceStart.getTime() + (1000*60);
application.raceStart.setProperty("start",application. myRaceStartMilli);
application.countDown = setInterval(application, "doCountDown", 1000, client);
}
application.doCountDown = function(client) {
client.initiator = true;
var myNowTime = new Date();
var myNow = myNowTime.getTime();
application.raceStart.setProperty("countDown", Math.round((application.myRaceStartMilli - myNow)/1000));
if (myNow >= application.myRaceStartMilli) {
//start the race
trace("INITIATING RACE");
application.raceStart.clear();
clearInterval(application.countDown);
application.initiateRace(client);
client.call("raceStartSetup", null);
}
trace("Race starts in " + Math.round((application.myRaceStartMilli - myNow)/1000));
}
On the client I will see the countdown from 59 all the way down, but for no reason that I can figure it stops usually around 5 seconds but sometimes as high as 25 seconds. Although I can see from traces on the server that the RSO is still changing and still counting down and once the countdown hits zero the client receives the initiation and everything works fine.
Can anyone tell me why a shared object fails to receive onSync events after a certain amount of time?
This e-mail and any attached files are for the exclusive use of the addressee and may contain privileged and/or confidential information. If you receive this e-mail in error you should not disclose the contents to any other person nor take copies but should delete it and telephone us immediately on +44(0)20 7440 1100.
TEQUILA\ London Limited does not make any warranty as to the accuracy or completeness of this e-mail and we accept no liability for its content or use. Any opinions expressed in this e-mail are those of the author and do not necessarily reflect the opinions of TEQUILA\ London Limited.
TEQUILA\ London Limited operates within the parameters set by the Data Protection Act 1998 with regard to the use of personal information including e-mail addresses. We accept no liability for the forwarding of this e-mail to other parties that may result in unsolicited e-mails being received by those whose email addresses appear in this e-mail.
|