protected function init() { new \ManiaLive\Features\Tick\Ticker(); $config = \ManiaLive\DedicatedApi\Config::getInstance(); $this->connection = Connection::factory($config->host, $config->port, $config->timeout, $config->user, $config->password); $this->connection->enableCallbacks(true); \ManiaLive\Data\Storage::getInstance(); \ManiaLive\Features\ChatCommand\Interpreter::getInstance(); \ManiaLive\Features\EchoHandler::getInstance(); \ManiaLive\Gui\GuiHandler::getInstance(); \ManiaLive\PluginHandler\PluginHandler::getInstance(); \ManiaLive\Threading\ThreadHandler::getInstance(); Dispatcher::dispatch(new Event(Event::ON_INIT)); }
public final function redraw($recipient = null) { if (!($this->recipient instanceof Group && $this->recipient->contains($recipient))) { $recipient = $this->recipient; } if (!($recipient instanceof Group || is_array($recipient))) { $recipient = array($recipient); } GuiHandler::getInstance()->addToRedraw($this, $recipient); }
function destroy() { parent::destroy(); $this->buttonMin = null; $this->buttonMax = null; $thumbnail = GuiHandler::getInstance()->getThumbnail($this); if ($thumbnail) { $thumbnail->destroy(); } }
function onDraw() { // statistics for memory usage $memory = memory_get_usage(); $text = '$oPHP Memory$z' . "\n" . 'Current Memory Usage: ' . round($memory / 1024) . " kb\n" . 'Total Peak Memory: ' . round(memory_get_peak_usage() / 1024) . " kb\n" . 'PHP Memory Limit: ' . round($this->memoryLimit / 1024) . " kb\n" . 'Amount Used: ' . round(100 * $memory / $this->memoryLimit, 2) . "%\n" . '$oPHP Speed$z' . "\n"; if (empty($this->cpuStats)) { $text .= '$iRetrieving information...$z' . "\n"; } else { $text .= 'Current Cycles per Second: ' . end($this->cpuStats) . "\n" . 'Avg Reaction Time: ' . round(1000 * count($this->cpuStats) / (array_sum($this->cpuStats) ?: 1)) . " msecs\n"; } // manialive specific stats $text .= '$oManiaLive$z' . "\n"; // runtime $diff = time() - \ManiaLive\Application\AbstractApplication::$startTime; $seconds = $diff % 60; $minutes = floor($diff % 3600 / 60); $hours = floor($diff % 86400 / 3600); $days = floor($diff / 86400); $text .= "ManiaLive Uptime:\n{$days} days and {$hours} hours\n{$minutes} min and {$seconds} seconds\n"; // threading $text .= '$oThreading$z' . "\n"; $processHandler = ThreadHandler::getInstance(); if ($processHandler->isEnabled()) { $text .= 'Enabled; Running:' . $processHandler->countThreads() . '; Restarted:' . $processHandler->countRestartedThreads() . "\n" . $processHandler->countFinishedCommands() . ' commands finished at avg ' . round($processHandler->getAverageResponseTime(), 3) . ' ms'; } else { $text .= "Disabled\n"; } // update left side of the page $this->leftLabel->setText($text); // database $text = '$oDatabase$z' . "\n"; $times = Connection::getMeasuredAverageTimes(); if (count($times)) { $i = 0; foreach ($times as $time) { $text .= 'Connection #' . ++$i . ":\n" . 'Avg Query Time: ' . round($time, 3) . ' sec' . "\n"; } } else { $text .= "No Database connections running.\n"; } // network $text .= '$oNetwork$z' . "\n" . 'Total Bytes Sent: ' . round(Client::$sent / 1024) . "kb\n" . 'Total Bytes Received: ' . round(Client::$received / 1024) . "kb\n" . '$oInterface Drawing$z' . "\n" . 'Avg Drawing Time: ' . round(GuiHandler::getInstance()->getAverageSendingTimes() * 1000) . " msec\n" . '$oPlugins$z' . "\n" . 'Currently loaded: ' . count(PluginHandler::getInstance()->getLoadedPluginsList()); // update right side of the page $this->rightLabel->setText($text); }