BrowserQuest项目有个地方是不是拼错了?

WGYHAPPY
2462 5 0
5个回答

WGYHAPPY

WorldServer.php 文件 1306行, updatePopulation函数:

public function updatePopulation($totalPlayers) 
{
    $this->pushBroadcast(new Messages\Population($this->playerCount, $totalPlayers ? $totalPlayers : $this->playerCount));
}
  • 暂无评论
walkor

额,没看出来哪里错了。
应该怎么拼呢?

  • 暂无评论
WGYHAPPY

下面是 Population 类:

<?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://www.workerman.net/
 * @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 一个 Messages\Population对象的时候,第一个参数不应该是一个worldServer的实例吗?好像不应该是$this->playerCount?

  • 暂无评论
walkor

没错

  • 暂无评论
WGYHAPPY

嗯。

  • 暂无评论
年代过于久远,无法发表回答
🔝