ITPub博客

首页 > 区块链 > 区块链 > “农民世界”链游系统开发应用场景讲解丨FarmersWorld(农民世界)DAPP游戏场景代码

“农民世界”链游系统开发应用场景讲解丨FarmersWorld(农民世界)DAPP游戏场景代码

原创 区块链 作者:Gb16978 时间:2022-07-21 14:45:05 0 删除 编辑

“农民世界”链游系统开发应用场景讲解丨FarmersWorld(农民世界)DAPP游戏系统开发场景代码讲解如下:

 /**

     * Save pid.

     *

     * @throws Exception

     */

“农民世界”链游接口:

protected static function saveMasterPid()
    {
        if (static::$_OS !== OS_TYPE_LINUX) {
            return;
        }
        static::$_masterPid = posix_getpid();
        if (false === file_put_contents(static::$pidFile, static::$_masterPid)) {
            throw new Exception('can not save pid to ' . static::$pidFile);
        }
    }

“农民世界”数据获取方式:

protected static function getEventLoopName()
    {
        if (static::$eventLoopClass) {
            return static::$eventLoopClass;
        }
        if (!class_exists('\Swoole\Event')) {
            unset(static::$_availableEventLoops['swoole']);
        }
        
        $loop_name = '';
        foreach (static::$_availableEventLoops as $name=>$class) {
            if (extension_loaded($name)) {
                $loop_name = $name;
                break;
            }
        }
        if ($loop_name) {
            if (interface_exists('\React\EventLoop\LoopInterface')) {
                switch ($loop_name) {
                    case 'libevent':
                        static::$eventLoopClass = '\Workerman\Events\React\ExtLibEventLoop';
                        break;
                    case 'event':
                        static::$eventLoopClass = '\Workerman\Events\React\ExtEventLoop';
                        break;
                    default :
                        static::$eventLoopClass = '\Workerman\Events\React\StreamSelectLoop';
                        break;
                }
            } else {
                static::$eventLoopClass = static::$_availableEventLoops[$loop_name];
            }
        } else {
            static::$eventLoopClass = interface_exists('\React\EventLoop\LoopInterface')? '\Workerman\Events\React\StreamSelectLoop':'\Workerman\Events\Select';
        }
        return static::$eventLoopClass;
    }


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/70019421/viewspace-2906954/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
软件开发:Gb16978 薇

注册时间:2022-06-28

  • 博文量
    15
  • 访问量
    6820