WorldServer.php 文件 1306行, updatePopulation函數(shù):
public function updatePopulation($totalPlayers)
{
$this->pushBroadcast(new Messages\Population($this->playerCount, $totalPlayers ? $totalPlayers : $this->playerCount));
}
下面是 Population 類(lèi):
<?php
/**
* This file is part of workerman.
*
* Licensed under The MIT License
* For full copyright and license information, please see the MIT-LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* @author walkor<walkor@workerman.net>
* @copyright walkor<walkor@workerman.net>
* @link http://wtbis.cn/
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Server\Messages;
class Population
{
public $world = 0;
public $total = 0;
public function __construct($world, $total)
{
$this->world = $world;
$this->total = $total;
}
public function serialize()
{
return array(TYPES_MESSAGES_POPULATION,
$this->world,
$this->total,
);
}
}
然后,new 一個(gè) Messages\Population對(duì)象的時(shí)候,第一個(gè)參數(shù)不應(yīng)該是一個(gè)worldServer的實(shí)例嗎?好像不應(yīng)該是$this->playerCount?