45 lines
1.1 KiB
ActionScript
45 lines
1.1 KiB
ActionScript
package net.pixvi.myr.center
|
|
{
|
|
import net.pixvi.common.driver.ClockDriver;
|
|
import net.pixvi.myr.net.NetSystem;
|
|
import net.pixvi.pfw.utils.core.Singleton;
|
|
|
|
public class TimeCenter
|
|
{
|
|
|
|
private var onStartTimeSynchroComplete:Function;
|
|
|
|
public function TimeCenter()
|
|
{
|
|
super();
|
|
}
|
|
|
|
public static function getIns() : TimeCenter
|
|
{
|
|
return Singleton.getInstanceOrCreate(TimeCenter);
|
|
}
|
|
|
|
public static function get timestamp() : Number
|
|
{
|
|
return ClockDriver.getInstance().timestamp;
|
|
}
|
|
|
|
public function startTimeSynchro(onsynchroComplete:Function = null) : void
|
|
{
|
|
onStartTimeSynchroComplete = onsynchroComplete;
|
|
NetSystem.getIns().synchroTime(startTimeSynchroHandler);
|
|
}
|
|
|
|
private function startTimeSynchroHandler(timeSecond:Number) : void
|
|
{
|
|
ClockDriver.getInstance().timestamp = timeSecond;
|
|
if(onStartTimeSynchroComplete != null)
|
|
{
|
|
onStartTimeSynchroComplete();
|
|
onStartTimeSynchroComplete = null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|