1: <?php
2: /**
3: * ManiaLive - TrackMania dedicated server manager in PHP
4: *
5: * @copyright Copyright (c) 2009-2011 NADEO (http://www.nadeo.com)
6: * @license http://www.gnu.org/licenses/lgpl.html LGPL License 3
7: * @version $Revision: 344 $:
8: * @author $Author: martin.gwendal $:
9: * @date $Date: 2012-03-20 16:36:40 +0100 (mar., 20 mars 2012) $:
10: */
11:
12: namespace ManiaLive\Features\Tick;
13:
14: use ManiaLive\Event\Dispatcher;
15: use ManiaLive\Application\Adapter as AppAdapter;
16: use ManiaLive\Application\Event as AppEvent;
17:
18: class Ticker extends AppAdapter
19: {
20: protected $time;
21:
22: function __construct()
23: {
24: $this->time = time();
25: Dispatcher::register(AppEvent::getClass(), $this, AppEvent::ON_PRE_LOOP);
26: }
27:
28: function onPreLoop()
29: {
30: $time = time();
31: if($time - $this->time >= 1)
32: {
33: $this->time = $time;
34: Dispatcher::dispatch(new Event());
35: }
36: }
37: }
38:
39: ?>