当前位置: 首页>>代码示例>>PHP>>正文


PHP MainLogger::getMessages方法代码示例

本文整理汇总了PHP中pocketmine\utils\MainLogger::getMessages方法的典型用法代码示例。如果您正苦于以下问题:PHP MainLogger::getMessages方法的具体用法?PHP MainLogger::getMessages怎么用?PHP MainLogger::getMessages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pocketmine\utils\MainLogger的用法示例。


在下文中一共展示了MainLogger::getMessages方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: run

 public function run()
 {
     while ($this->stop !== true) {
         $this->synchronized(function () {
             $this->wait(2000);
         });
         $r = [$socket = $this->socket];
         $w = null;
         $e = null;
         if (socket_select($r, $w, $e, 0) === 1) {
             if (($client = socket_accept($this->socket)) !== false) {
                 socket_set_block($client);
                 socket_set_option($client, SOL_SOCKET, SO_KEEPALIVE, 1);
                 $done = false;
                 for ($n = 0; $n < $this->maxClients; ++$n) {
                     if ($this->{"client" . $n} === null) {
                         $this->{"client" . $n} = $client;
                         $this->{"status" . $n} = 0;
                         $this->{"timeout" . $n} = microtime(true) + 5;
                         $done = true;
                         break;
                     }
                 }
                 if ($done === false) {
                     @socket_close($client);
                 }
             }
         }
         for ($n = 0; $n < $this->maxClients; ++$n) {
             $client =& $this->{"client" . $n};
             if ($client !== null) {
                 if ($this->{"status" . $n} !== -1 and $this->stop !== true) {
                     if ($this->{"status" . $n} === 0 and $this->{"timeout" . $n} < microtime(true)) {
                         //Timeout
                         $this->{"status" . $n} = -1;
                         continue;
                     }
                     $p = $this->readPacket($client, $size, $requestID, $packetType, $payload);
                     if ($p === false) {
                         $this->{"status" . $n} = -1;
                         continue;
                     } elseif ($p === null) {
                         continue;
                     }
                     switch ($packetType) {
                         case 9:
                             //Protocol check
                             if ($this->{"status" . $n} !== 1) {
                                 $this->{"status" . $n} = -1;
                                 continue;
                             }
                             $this->writePacket($client, $requestID, 0, RCON::PROTOCOL_VERSION);
                             $this->response = "";
                             if ($payload == RCON::PROTOCOL_VERSION) {
                                 $this->logger->setSendMsg(true);
                             }
                             //GeniRCON output
                             break;
                         case 4:
                             //Logger
                             if ($this->{"status" . $n} !== 1) {
                                 $this->{"status" . $n} = -1;
                                 continue;
                             }
                             $this->writePacket($client, $requestID, 0, str_replace("\n", "\r\n", trim($this->logger->getMessages())));
                             $this->response = "";
                             break;
                         case 3:
                             //Login
                             if ($this->{"status" . $n} !== 0) {
                                 $this->{"status" . $n} = -1;
                                 continue;
                             }
                             if ($payload === $this->password) {
                                 socket_getpeername($client, $addr, $port);
                                 $this->response = "[INFO] Successful Rcon connection from: /{$addr}:{$port}";
                                 $this->response = "";
                                 $this->writePacket($client, $requestID, 2, "");
                                 $this->{"status" . $n} = 1;
                             } else {
                                 $this->{"status" . $n} = -1;
                                 $this->writePacket($client, -1, 2, "");
                                 continue;
                             }
                             break;
                         case 2:
                             //Command
                             if ($this->{"status" . $n} !== 1) {
                                 $this->{"status" . $n} = -1;
                                 continue;
                             }
                             if (strlen($payload) > 0) {
                                 $this->cmd = ltrim($payload);
                                 $this->synchronized(function () {
                                     $this->waiting = true;
                                     $this->wait();
                                 });
                                 $this->waiting = false;
                                 $this->writePacket($client, $requestID, 0, str_replace("\n", "\r\n", trim($this->response)));
                                 $this->response = "";
//.........这里部分代码省略.........
开发者ID:xpyctum,项目名称:Genisys,代码行数:101,代码来源:RCONInstance.php


注:本文中的pocketmine\utils\MainLogger::getMessages方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。