d3lph1/minecraft-rcon-manager
Composer 安装命令:
composer require d3lph1/minecraft-rcon-manager
包简介
Library for easy interaction with the minecraft server using rcon.
关键字:
README 文档
README
Library for easy interaction with the minecraft server using rcon.
Installation
Execute command:
composer require d3lph1/minecraft-rcon-manager ~1.0
or add line to require section of composer.json
"d3lph1/minecraft-rcon-manage": "~1.0",
Usage
Overview
use \D3lph1\MinecraftRconManager\DefaultConnector; use \D3lph1\MinecraftRconManager\Exceptions\ConnectSocketException; use \D3lph1\MinecraftRconManager\Exceptions\AccessDenyException; $connector = new DefaultConnector(); try { // Connect to RCON $rcon = $connector->connect('127.0.0.1', 25575, '123456'); }catch(ConnectSocketException $e) { // do something... }catch(AccessDenyException $e) { // do something... } // Get only response body $response = $rcon->send('say Yes, it works...'); print_r($response); // §d[Rcon§d] Yes, it works... // Get response array $response = $rcon->send('say Yes, it works...', true); print_r($response); /** * Array ( * [id] => 16 * [type] => 0 * [body] => §d[Rcon§d] Yes, it works... * ) * */ // Get last response $last = $rcon->getLast(); // Close RCON connection $rcon->disconnect();
Connecting
First, you need to create an instance of the Connector class. The instance will serve to create a connection to the server, add servers to the pool and remove them from there.
use \D3lph1\MinecraftRconManager\DefaultConnector; $connector = new DefaultConnector();
In order to connect directly to the server, use this construction
$rcon = $connector->connect($host, $port, $password, $timeout);
Where:
$host- Server host (By default,127.0.0.1)$port- Rcon port (By default,25575)$password- Rcon password$timeout- Connection timeout (By default,1second)
You can also add the server to the server pool in order to get the connection instance later:
$connector->add($name, $host, $port, $password, $timeout); // Still as an option... $connector->add('hi_tech', [ 'host' => '127.0.0.1', 'port' => 25575, 'password' => '123456', 'timeout' => 1 ]); // Since the Connector class implements the ArrayAccess interface, // the servers can be placed into the pool by accessing the object as an array. $connector['mmo'] = [ 'host' => '127.0.0.1', 'port' => 25576, 'password' => '123456', 'timeout' => 1 ];
Ok, now we need the servers in the pool. Now that you need a server in the future, you will pull it out of the pool like this:
$rcon = $connector->get('hi_tech'); // Or... $rcon = $connector['mmo'];
Remove server from server pool:
$connector->remove('hi_tech'); // or... unset($connector['hi_tech']);
Sending requests
Using the constructs described above, we get an instance of the class D3lph1\MinecraftRconManager\Rcon with which we can finally send requests to our server:
$response = $rcon->send('say Yes, it works...');
In return we will get something like this: §d[Rcon§d] Yes, it works...
You can get not only the body of the answer but the entire array in which besides the body contains also the service information. Just pass true to the second argument to send().
$response = $rcon->send('say Yes, it works...', true);
This array contains element type - the type of request (authorization or command execution) and the request id - required to check the integrity of the response.
Get data from last request:
$response = $rcon->last();
Disconnect from server:
$rcon->disconnect();
d3lph1/minecraft-rcon-manager 适用场景与选型建议
d3lph1/minecraft-rcon-manager 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.07k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2017 年 03 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「rcon」 「minecraft」 「mc」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 d3lph1/minecraft-rcon-manager 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 d3lph1/minecraft-rcon-manager 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 d3lph1/minecraft-rcon-manager 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Allow users to use the head of a Minecraft skin as avatar.
The library is designed to integrate the minecraft server with the website.
PHP library to request RCON for Minecraft servers
PHP RCON Client
PHP library retrieve game servers status from various types of games.
Minecraft rcon request library
统计信息
- 总下载量: 3.07k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 6
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-03-19