Last active
May 12, 2019 14:07
-
-
Save yuyaprgrm/00e655754585016d59dddbaaa69950c5 to your computer and use it in GitHub Desktop.
PocketMine-MPのAsyncTaskのサンプル
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * Created by PhpStorm. | |
| * User: tokai | |
| * Date: 2018/03/01 | |
| * Time: 19:35 | |
| */ | |
| namespace MasterF\PocketMineGUI\task; | |
| use pocketmine\scheduler\AsyncTask; | |
| use pocketmine\Server; | |
| class GUIConnectionTask extends AsyncTask | |
| { | |
| /** | |
| * Actions to execute when run | |
| * | |
| * @return void | |
| */ | |
| public function onRun() | |
| { | |
| $sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); | |
| // socket_bind($sock, "127.0.0.1"); | |
| socket_connect($sock, "127.0.0.1",20132); | |
| $message = socket_read($sock, 512, PHP_NORMAL_READ); | |
| $this->setResult($message, false); | |
| } | |
| public function onCompletion(Server $server) | |
| { | |
| $message = $this->getResult(); | |
| $server->getLogger()->info("From PocketMineGUI: ${message}"); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
gay