2013-11-09 17:24:03 +01:00
|
|
|
<?php
|
|
|
|
|
2013-11-12 15:48:25 +01:00
|
|
|
namespace ManiaControl\Callbacks;
|
|
|
|
|
2017-05-10 12:40:00 +02:00
|
|
|
use ManiaControl\ErrorHandler;
|
2017-03-26 19:44:55 +02:00
|
|
|
use ManiaControl\General\UsageInformationAble;
|
|
|
|
use ManiaControl\General\UsageInformationTrait;
|
2017-05-13 15:13:33 +02:00
|
|
|
use ManiaControl\Logger;
|
2013-11-12 15:48:25 +01:00
|
|
|
use ManiaControl\ManiaControl;
|
2017-05-11 21:33:07 +02:00
|
|
|
use Maniaplanet\DedicatedServer\Xmlrpc\ParseException;
|
2013-11-09 17:24:03 +01:00
|
|
|
|
|
|
|
/**
|
2014-01-09 20:38:45 +01:00
|
|
|
* Class for managing Server and ManiaControl Callbacks
|
2013-11-09 17:24:03 +01:00
|
|
|
*
|
2014-05-02 17:50:30 +02:00
|
|
|
* @author ManiaControl Team <mail@maniacontrol.com>
|
2017-02-04 11:49:23 +01:00
|
|
|
* @copyright 2014-2017 ManiaControl Team
|
2014-04-24 21:55:47 +02:00
|
|
|
* @license http://www.gnu.org/licenses/ GNU General Public License, Version 3
|
2013-11-09 17:24:03 +01:00
|
|
|
*/
|
2017-03-26 19:44:55 +02:00
|
|
|
class CallbackManager implements UsageInformationAble {
|
|
|
|
use UsageInformationTrait;
|
2017-05-08 19:55:07 +02:00
|
|
|
|
2014-04-12 12:14:37 +02:00
|
|
|
/*
|
2013-11-09 17:24:03 +01:00
|
|
|
* Constants
|
|
|
|
*/
|
|
|
|
// ManiaPlanet callbacks
|
2014-04-24 21:55:47 +02:00
|
|
|
const CB_MP_SERVERSTART = 'ManiaPlanet.ServerStart';
|
|
|
|
const CB_MP_SERVERSTOP = 'ManiaPlanet.ServerStop';
|
|
|
|
const CB_MP_BEGINMATCH = 'ManiaPlanet.BeginMatch';
|
|
|
|
const CB_MP_ENDMATCH = 'ManiaPlanet.EndMatch';
|
2014-06-14 17:10:19 +02:00
|
|
|
const CB_MP_BEGINMAP = 'ManiaPlanet.BeginMap';
|
|
|
|
const CB_MP_ENDMAP = 'ManiaPlanet.EndMap';
|
2014-04-24 21:55:47 +02:00
|
|
|
const CB_MP_MAPLISTMODIFIED = 'ManiaPlanet.MapListModified';
|
|
|
|
const CB_MP_ECHO = 'ManiaPlanet.Echo';
|
|
|
|
const CB_MP_BILLUPDATED = 'ManiaPlanet.BillUpdated';
|
|
|
|
const CB_MP_PLAYERCHAT = 'ManiaPlanet.PlayerChat';
|
|
|
|
const CB_MP_PLAYERCONNECT = 'ManiaPlanet.PlayerConnect';
|
|
|
|
const CB_MP_PLAYERDISCONNECT = 'ManiaPlanet.PlayerDisconnect';
|
2013-11-09 17:24:03 +01:00
|
|
|
const CB_MP_PLAYERMANIALINKPAGEANSWER = 'ManiaPlanet.PlayerManialinkPageAnswer';
|
2014-04-24 21:55:47 +02:00
|
|
|
const CB_MP_PLAYERINFOCHANGED = 'ManiaPlanet.PlayerInfoChanged';
|
|
|
|
const CB_MP_PLAYERALLIESCHANGED = 'ManiaPlanet.PlayerAlliesChanged';
|
|
|
|
const CB_MP_VOTEUPDATED = 'ManiaPlanet.VoteUpdated';
|
|
|
|
const CB_MP_STATUSCHANGED = 'ManiaPlanet.StatusChanged';
|
|
|
|
const CB_MP_MODESCRIPTCALLBACK = 'ManiaPlanet.ModeScriptCallback';
|
|
|
|
const CB_MP_MODESCRIPTCALLBACKARRAY = 'ManiaPlanet.ModeScriptCallbackArray';
|
|
|
|
const CB_MP_TUNNELDATARECEIVED = 'ManiaPlanet.TunnelDataReceived';
|
|
|
|
|
2013-11-09 17:24:03 +01:00
|
|
|
// TrackMania callbacks
|
2014-04-24 21:55:47 +02:00
|
|
|
const CB_TM_PLAYERCHECKPOINT = 'TrackMania.PlayerCheckpoint';
|
|
|
|
const CB_TM_PLAYERFINISH = 'TrackMania.PlayerFinish';
|
2013-11-09 17:24:03 +01:00
|
|
|
const CB_TM_PLAYERINCOHERENCE = 'TrackMania.PlayerIncoherence';
|
2014-04-24 21:55:47 +02:00
|
|
|
|
2014-03-19 21:58:11 +01:00
|
|
|
/*
|
2014-07-25 16:39:07 +02:00
|
|
|
* Private properties
|
2013-11-09 17:24:03 +01:00
|
|
|
*/
|
2017-04-02 16:25:04 +02:00
|
|
|
private $libXmlRpcCallbacks = null;
|
|
|
|
private $shootManiaCallbacks = null;
|
|
|
|
private $trackManiaCallbacks = null;
|
|
|
|
|
|
|
|
|
2014-07-25 16:39:07 +02:00
|
|
|
/** @var ManiaControl $maniaControl */
|
2013-11-10 02:55:08 +01:00
|
|
|
private $maniaControl = null;
|
2014-07-11 16:54:43 +02:00
|
|
|
/** @var Listening[][] $callbackListenings */
|
2014-05-13 01:18:47 +02:00
|
|
|
private $callbackListenings = array();
|
2014-07-11 16:54:43 +02:00
|
|
|
/** @var Listening[][] $scriptCallbackListenings */
|
2014-05-13 01:18:47 +02:00
|
|
|
private $scriptCallbackListenings = array();
|
2014-01-09 20:38:45 +01:00
|
|
|
|
2013-11-09 17:24:03 +01:00
|
|
|
/**
|
2014-07-25 16:39:07 +02:00
|
|
|
* Construct a new callbacks manager instance
|
2013-11-10 02:55:08 +01:00
|
|
|
*
|
2014-05-13 01:18:47 +02:00
|
|
|
* @param ManiaControl $maniaControl
|
2013-11-09 17:24:03 +01:00
|
|
|
*/
|
2013-11-10 02:55:08 +01:00
|
|
|
public function __construct(ManiaControl $maniaControl) {
|
|
|
|
$this->maniaControl = $maniaControl;
|
2014-04-24 21:55:47 +02:00
|
|
|
|
2014-05-13 01:18:47 +02:00
|
|
|
$this->libXmlRpcCallbacks = new LibXmlRpcCallbacks($maniaControl, $this);
|
2014-05-24 17:45:35 +02:00
|
|
|
$this->shootManiaCallbacks = new ShootManiaCallbacks($maniaControl, $this);
|
|
|
|
$this->trackManiaCallbacks = new TrackManiaCallbacks($maniaControl, $this);
|
2013-11-09 17:24:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-01-09 20:38:45 +01:00
|
|
|
* Register a new Callback Listener
|
2013-11-12 15:48:25 +01:00
|
|
|
*
|
2014-05-13 01:18:47 +02:00
|
|
|
* @param string $callbackName
|
|
|
|
* @param CallbackListener $listener
|
|
|
|
* @param string $method
|
2013-11-12 15:48:25 +01:00
|
|
|
* @return bool
|
2013-11-09 17:24:03 +01:00
|
|
|
*/
|
2013-11-12 15:48:25 +01:00
|
|
|
public function registerCallbackListener($callbackName, CallbackListener $listener, $method) {
|
2014-05-13 01:18:47 +02:00
|
|
|
if (is_array($callbackName)) {
|
2014-07-11 16:54:43 +02:00
|
|
|
$success = false;
|
2014-05-13 01:18:47 +02:00
|
|
|
foreach ($callbackName as $callback) {
|
2014-07-11 16:54:43 +02:00
|
|
|
if ($this->registerCallbackListener($callback, $listener, $method)) {
|
|
|
|
$success = true;
|
2014-05-13 01:18:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return $success;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!Listening::checkValidCallback($listener, $method)) {
|
|
|
|
$listenerClass = get_class($listener);
|
|
|
|
trigger_error("Given Listener '{$listenerClass}' can't handle Callback '{$callbackName}': No callable Method '{$method}'!");
|
2013-11-12 15:48:25 +01:00
|
|
|
return false;
|
2013-11-09 17:24:03 +01:00
|
|
|
}
|
2014-05-13 01:18:47 +02:00
|
|
|
|
2017-03-25 13:40:37 +01:00
|
|
|
if (!$this->callbackListeningExists($callbackName)) {
|
2014-05-13 01:18:47 +02:00
|
|
|
$this->callbackListenings[$callbackName] = array();
|
2013-11-12 15:48:25 +01:00
|
|
|
}
|
2014-05-13 01:18:47 +02:00
|
|
|
|
|
|
|
$listening = new Listening($listener, $method);
|
|
|
|
array_push($this->callbackListenings[$callbackName], $listening);
|
|
|
|
|
2013-11-12 15:48:25 +01:00
|
|
|
return true;
|
2013-11-09 17:24:03 +01:00
|
|
|
}
|
|
|
|
|
2017-03-25 13:40:37 +01:00
|
|
|
/**
|
|
|
|
* Checks if a Callback Listening exists
|
|
|
|
*
|
|
|
|
* @param $callbackName
|
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function callbackListeningExists($callbackName) {
|
|
|
|
return array_key_exists($callbackName, $this->callbackListenings);
|
|
|
|
}
|
|
|
|
|
2013-11-25 19:46:29 +01:00
|
|
|
/**
|
2014-01-09 20:38:45 +01:00
|
|
|
* Register a new Script Callback Listener
|
2013-11-25 19:46:29 +01:00
|
|
|
*
|
2014-04-24 21:55:47 +02:00
|
|
|
* @param string $callbackName
|
2014-01-09 20:38:45 +01:00
|
|
|
* @param CallbackListener $listener
|
2014-04-24 21:55:47 +02:00
|
|
|
* @param string $method
|
2013-11-25 19:46:29 +01:00
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function registerScriptCallbackListener($callbackName, CallbackListener $listener, $method) {
|
2014-05-13 01:18:47 +02:00
|
|
|
if (is_array($callbackName)) {
|
2014-07-11 16:54:43 +02:00
|
|
|
$success = false;
|
2014-05-13 01:18:47 +02:00
|
|
|
foreach ($callbackName as $callback) {
|
2014-07-11 16:54:43 +02:00
|
|
|
if ($this->registerScriptCallbackListener($callback, $listener, $method)) {
|
|
|
|
$success = true;
|
2014-05-13 01:18:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return $success;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!Listening::checkValidCallback($listener, $method)) {
|
|
|
|
$listenerClass = get_class($listener);
|
|
|
|
trigger_error("Given Listener '{$listenerClass}' can't handle Script Callback '{$callbackName}': No callable Method '{$method}'!");
|
2013-11-25 19:46:29 +01:00
|
|
|
return false;
|
|
|
|
}
|
2014-05-13 01:18:47 +02:00
|
|
|
|
|
|
|
if (!array_key_exists($callbackName, $this->scriptCallbackListenings)) {
|
|
|
|
$this->scriptCallbackListenings[$callbackName] = array();
|
2013-11-25 19:46:29 +01:00
|
|
|
}
|
2014-05-13 01:18:47 +02:00
|
|
|
|
|
|
|
$listening = new Listening($listener, $method);
|
|
|
|
array_push($this->scriptCallbackListenings[$callbackName], $listening);
|
|
|
|
|
2013-11-25 19:46:29 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-12-14 23:27:15 +01:00
|
|
|
/**
|
2014-05-13 01:18:47 +02:00
|
|
|
* Unregister a Callback Listener
|
2013-12-14 23:27:15 +01:00
|
|
|
*
|
2014-01-09 20:38:45 +01:00
|
|
|
* @param CallbackListener $listener
|
2013-12-14 23:27:15 +01:00
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function unregisterCallbackListener(CallbackListener $listener) {
|
2014-05-13 01:18:47 +02:00
|
|
|
return $this->removeCallbackListener($this->callbackListenings, $listener);
|
|
|
|
}
|
|
|
|
|
2014-07-04 11:34:17 +02:00
|
|
|
/**
|
2014-07-11 16:54:43 +02:00
|
|
|
* Remove the Callback Listener from the given Listeners Array
|
2014-07-04 11:34:17 +02:00
|
|
|
*
|
2014-07-11 16:54:43 +02:00
|
|
|
* @param Listening[] $listeningsArray
|
2014-07-04 11:34:17 +02:00
|
|
|
* @param CallbackListener $listener
|
|
|
|
* @return bool
|
|
|
|
*/
|
2014-07-11 16:54:43 +02:00
|
|
|
private function removeCallbackListener(array &$listeningsArray, CallbackListener $listener) {
|
|
|
|
$removed = false;
|
|
|
|
foreach ($listeningsArray as &$listenings) {
|
2014-07-04 11:34:17 +02:00
|
|
|
foreach ($listenings as $key => &$listening) {
|
2014-07-11 16:54:43 +02:00
|
|
|
if ($listening->listener === $listener) {
|
2014-07-04 11:34:17 +02:00
|
|
|
unset($listenings[$key]);
|
2014-07-11 16:54:43 +02:00
|
|
|
$removed = true;
|
2014-07-04 11:34:17 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-07-11 16:54:43 +02:00
|
|
|
return $removed;
|
2014-07-04 11:34:17 +02:00
|
|
|
}
|
|
|
|
|
2014-05-13 01:18:47 +02:00
|
|
|
/**
|
2014-07-11 16:54:43 +02:00
|
|
|
* Unregister a single Callback Listening from an Callback Listener
|
2014-05-13 01:18:47 +02:00
|
|
|
*
|
2014-07-11 16:54:43 +02:00
|
|
|
* @param String $callbackName
|
2014-05-13 01:18:47 +02:00
|
|
|
* @param CallbackListener $listener
|
|
|
|
* @return bool
|
|
|
|
*/
|
2014-07-11 16:54:43 +02:00
|
|
|
public function unregisterCallbackListening($callbackName, CallbackListener $listener) {
|
2013-12-14 23:27:15 +01:00
|
|
|
$removed = false;
|
2014-07-11 16:54:43 +02:00
|
|
|
foreach ($this->callbackListenings as &$listenings) {
|
2014-05-13 01:18:47 +02:00
|
|
|
foreach ($listenings as $key => &$listening) {
|
2014-07-11 16:54:43 +02:00
|
|
|
if ($key === $callbackName && $listening->listener === $listener) {
|
2014-05-13 01:18:47 +02:00
|
|
|
unset($listenings[$key]);
|
2014-05-07 23:00:21 +02:00
|
|
|
$removed = true;
|
2014-01-19 23:18:48 +01:00
|
|
|
}
|
2013-12-14 23:27:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return $removed;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2014-05-13 01:18:47 +02:00
|
|
|
* Unregister a Script Callback Listener
|
2013-12-14 23:27:15 +01:00
|
|
|
*
|
2014-01-09 20:38:45 +01:00
|
|
|
* @param CallbackListener $listener
|
2013-12-14 23:27:15 +01:00
|
|
|
* @return bool
|
|
|
|
*/
|
|
|
|
public function unregisterScriptCallbackListener(CallbackListener $listener) {
|
2014-05-13 01:18:47 +02:00
|
|
|
return $this->removeCallbackListener($this->scriptCallbackListenings, $listener);
|
2013-12-14 23:27:15 +01:00
|
|
|
}
|
|
|
|
|
2013-11-12 15:48:25 +01:00
|
|
|
/**
|
2014-01-09 20:38:45 +01:00
|
|
|
* Trigger internal Callbacks and manage Server Callbacks
|
2013-11-12 15:48:25 +01:00
|
|
|
*/
|
|
|
|
public function manageCallbacks() {
|
2014-01-31 00:04:40 +01:00
|
|
|
// Manage Timings
|
2014-08-13 11:05:52 +02:00
|
|
|
$this->maniaControl->getTimerManager()->manageTimings();
|
2014-04-24 21:55:47 +02:00
|
|
|
|
2015-06-21 20:45:48 +02:00
|
|
|
// Manage Socket Tickets
|
2015-06-22 20:22:17 +02:00
|
|
|
$this->maniaControl->getCommunicationManager()->tick();
|
2015-06-21 20:45:48 +02:00
|
|
|
|
2014-01-09 20:38:45 +01:00
|
|
|
// Server Callbacks
|
2014-08-03 01:34:18 +02:00
|
|
|
if (!$this->maniaControl->getClient()) {
|
2014-01-19 23:18:48 +01:00
|
|
|
return;
|
|
|
|
}
|
2014-04-24 21:55:47 +02:00
|
|
|
|
2013-11-09 17:24:03 +01:00
|
|
|
// Handle callbacks
|
2017-05-11 22:28:33 +02:00
|
|
|
$timings = array();
|
|
|
|
$startTime = microtime(true);
|
|
|
|
|
|
|
|
try {
|
|
|
|
$callbacks = $this->maniaControl->getClient()->executeCallbacks();
|
|
|
|
} catch (ParseException $e) {
|
|
|
|
//TODO remove later, its for the wrong XML encoding of nadeo
|
2017-05-13 15:13:33 +02:00
|
|
|
Logger::logError("Parse Exception");
|
2017-05-11 22:28:33 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-05-10 11:07:45 +02:00
|
|
|
$timings["executeCallbacks"] = microtime(true) - $startTime;
|
2017-05-11 22:28:33 +02:00
|
|
|
|
2017-05-10 12:40:00 +02:00
|
|
|
foreach ($callbacks as $key => $callback) {
|
2017-05-10 11:07:45 +02:00
|
|
|
$time1 = microtime(true);
|
2014-03-19 21:58:11 +01:00
|
|
|
$this->handleCallback($callback);
|
2017-05-10 12:40:00 +02:00
|
|
|
$timings[$key] = array($callback[0], microtime(true) - $time1);
|
2017-05-10 11:07:45 +02:00
|
|
|
}
|
|
|
|
|
2017-05-14 09:25:52 +02:00
|
|
|
//Execute Multicalls
|
|
|
|
$this->maniaControl->getClient()->executeMulticall();
|
|
|
|
|
2017-05-10 11:09:59 +02:00
|
|
|
$fullTime = microtime(true) - $startTime;
|
2017-05-14 09:25:52 +02:00
|
|
|
|
2017-05-10 12:40:00 +02:00
|
|
|
if ($fullTime > ErrorHandler::LONG_LOOP_REPORT_TIME) {
|
|
|
|
$this->maniaControl->getErrorHandler()->triggerDebugNotice(json_encode(array("Long Loop Detected: " . $fullTime, $timings)));
|
2014-03-19 21:58:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Handle the given Callback
|
|
|
|
*
|
|
|
|
* @param array $callback
|
|
|
|
*/
|
|
|
|
private function handleCallback(array $callback) {
|
|
|
|
$callbackName = $callback[0];
|
2014-05-02 17:50:30 +02:00
|
|
|
switch ($callbackName) {
|
2014-06-14 17:10:19 +02:00
|
|
|
case self::CB_MP_BEGINMATCH:
|
2014-05-09 12:19:06 +02:00
|
|
|
$this->triggerCallback($callbackName, $callback);
|
2014-05-02 17:50:30 +02:00
|
|
|
break;
|
2014-06-14 17:10:19 +02:00
|
|
|
case self::CB_MP_BEGINMAP:
|
2014-08-13 11:05:52 +02:00
|
|
|
$this->maniaControl->getMapManager()->handleBeginMap($callback);
|
2014-03-19 21:58:11 +01:00
|
|
|
$this->triggerCallback($callbackName, $callback);
|
|
|
|
break;
|
2014-06-14 17:10:19 +02:00
|
|
|
case self::CB_MP_ENDMATCH:
|
2014-05-09 12:14:25 +02:00
|
|
|
$this->triggerCallback($callbackName, $callback);
|
2014-05-02 17:50:30 +02:00
|
|
|
break;
|
2014-06-14 17:10:19 +02:00
|
|
|
case self::CB_MP_ENDMAP:
|
2014-08-13 11:05:52 +02:00
|
|
|
$this->maniaControl->getMapManager()->handleEndMap($callback);
|
2014-03-19 21:58:11 +01:00
|
|
|
$this->triggerCallback($callbackName, $callback);
|
|
|
|
break;
|
|
|
|
case self::CB_MP_MODESCRIPTCALLBACK:
|
|
|
|
$this->handleScriptCallback($callback);
|
|
|
|
$this->triggerCallback($callbackName, $callback);
|
|
|
|
break;
|
|
|
|
case self::CB_MP_MODESCRIPTCALLBACKARRAY:
|
|
|
|
$this->handleScriptCallback($callback);
|
|
|
|
$this->triggerCallback($callbackName, $callback);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
$this->triggerCallback($callbackName, $callback);
|
|
|
|
break;
|
2013-11-09 17:24:03 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-02 17:50:30 +02:00
|
|
|
/**
|
|
|
|
* Trigger a specific Callback
|
|
|
|
*
|
2017-05-08 19:55:07 +02:00
|
|
|
* @param mixed $callbackName
|
2014-05-02 17:50:30 +02:00
|
|
|
*/
|
2017-05-08 19:55:07 +02:00
|
|
|
public function triggerCallback($callbackName) {
|
|
|
|
|
2017-03-25 13:40:37 +01:00
|
|
|
if (!$this->callbackListeningExists($callbackName)) {
|
2014-05-02 17:50:30 +02:00
|
|
|
return;
|
|
|
|
}
|
2014-05-13 01:18:47 +02:00
|
|
|
|
2014-05-02 17:50:30 +02:00
|
|
|
$params = func_get_args();
|
2017-05-08 19:55:07 +02:00
|
|
|
$params = array_slice($params, 1, null, true);
|
2014-05-13 01:18:47 +02:00
|
|
|
|
|
|
|
foreach ($this->callbackListenings[$callbackName] as $listening) {
|
2017-05-11 22:28:33 +02:00
|
|
|
/** @var Listening $listening */
|
|
|
|
$listening->triggerCallbackWithParams($params);
|
2014-05-02 17:50:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-09 17:24:03 +01:00
|
|
|
/**
|
2014-01-09 20:38:45 +01:00
|
|
|
* Handle the given Script Callback
|
2013-11-09 17:24:03 +01:00
|
|
|
*
|
2014-01-09 20:38:45 +01:00
|
|
|
* @param array $callback
|
2013-11-09 17:24:03 +01:00
|
|
|
*/
|
2013-11-12 15:48:25 +01:00
|
|
|
private function handleScriptCallback(array $callback) {
|
2013-11-25 19:46:29 +01:00
|
|
|
$scriptCallbackData = $callback[1];
|
|
|
|
$scriptCallbackName = $scriptCallbackData[0];
|
2014-03-19 21:58:11 +01:00
|
|
|
$this->triggerScriptCallback($scriptCallbackName, $scriptCallbackData);
|
2014-04-24 21:55:47 +02:00
|
|
|
$this->triggerCallback(Callbacks::SCRIPTCALLBACK, $scriptCallbackName, $scriptCallbackData[1]);
|
2013-11-09 17:24:03 +01:00
|
|
|
}
|
2014-05-02 17:50:30 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Trigger a specific Script Callback
|
|
|
|
*
|
|
|
|
* @param string $callbackName
|
|
|
|
*/
|
|
|
|
public function triggerScriptCallback($callbackName) {
|
2014-05-13 01:18:47 +02:00
|
|
|
if (!array_key_exists($callbackName, $this->scriptCallbackListenings)) {
|
2014-05-02 17:50:30 +02:00
|
|
|
return;
|
|
|
|
}
|
2014-05-13 01:18:47 +02:00
|
|
|
|
2014-05-02 17:50:30 +02:00
|
|
|
$params = func_get_args();
|
2014-05-13 01:18:47 +02:00
|
|
|
$params = array_slice($params, 1, null, true);
|
|
|
|
|
|
|
|
foreach ($this->scriptCallbackListenings[$callbackName] as $listening) {
|
2014-07-17 20:02:36 +02:00
|
|
|
/** @var Listening $listening */
|
2014-05-13 01:18:47 +02:00
|
|
|
$listening->triggerCallbackWithParams($params);
|
2014-05-02 17:50:30 +02:00
|
|
|
}
|
|
|
|
}
|
2013-11-09 17:24:03 +01:00
|
|
|
}
|