MeepoPS基本使用方法

MeepoPS基本使用

  

  MeepoPS是Meepo PHP Socket的縮寫. 旨在提供高效穩定的由純PHP開發的多進程SocketService。
  MeepoPS能夠輕鬆構建在線實時聊天, 即時遊戲, 視頻流媒體播放, RPC, 以及本來使用HTTP的接口/定時任務的場景中等。php


(1)MeepoPS的最低運行要求是安裝了PHP的PCNTL庫,檢查php是否安裝了PCNTL庫。linux


 

(2)下載socket:git

  sudo apt-get install socketgithub


 

(3)下載MeepoPS的demo:ubuntu

  https://github.com/lixuancn/MeepoPS/archive/master.zip服務器

  解壓傳輸到linux服務器上。socket


 (4)進入到解壓後的目錄spa

  修改demo-telnet.php的主機地址爲127.0.0.1,端口爲8080。調試

  執行:sudo php demo-telnet.php startcode

test@localhost:/wwwroot/meepoPS$ sudo php demo-telnet.php start
MeepoPS Start:                         [OK]
-------------------------- MeepoPS Start Success ------------------------
MeepoPS Version: 0.0.5 | PHP Version: 5.3.10-1ubuntu3.26 | Master Pid: 4556 | Event: Select
-------------------------- Instances List -------------------------
MeepoPS-Telnet  telnet://127.0.0.1:8080  Child Process: 1

再開啓一個窗口,而後使用ps aux | grep php,能夠看到已經啓動成功:

test@localhost:~$ ps aux | grep php
root       4310  0.0  0.2  58488  2196 pts/1    S+   15:48   0:00 sudo php demo-telnet.php start
root       4311  0.0  1.1 248236 11372 pts/1    S+   15:48   0:00 php demo-telnet.php start
root       4313  0.0  0.5 248236  5804 pts/1    S+   15:48   0:00 php demo-telnet.php start
test       4522  0.0  0.0  11728   972 pts/3    S+   15:51   0:00 grep --color=auto php

  鏈接:

  telnet 127.0.0.1:8080

  

test@localhost:/wwwroot/meepoPS$ telnet 127.0.0.1:8080
telnet: could not resolve 127.0.0.1:8080/telnet: Name or service not known
test@localhost:/wwwroot/meepoPS$ telnet 127.0.0.1 8080
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.

  而後就能夠發消息,兩個窗口均可以收到。


 http 方式

   修改demp-http.php文件:

  $http = new \MeepoPS\Api\Http('0.0.0.0', '8080');
  $http->setDocument('127.0.0.1:8080','/wwwroot/MeepoPS/');

  保存退出,啓動demo-http.php(若是有錯誤,可使用:set nu 顯示行號進行調試)

相關文章
相關標籤/搜索