MeepoPS基本使用方法

MeepoPS基本使用

  

  MeepoPS是Meepo PHP Socket的缩写. 旨在提供高效稳定的由纯PHP开发的多进程SocketService。
  MeepoPS可以轻松构建在线实时聊天, 即时游戏, 视频流媒体播放, RPC, 以及原本使用HTTP的接口/定时任务的场景中等。


(1)MeepoPS的最低运行要求是安装了PHP的PCNTL库,检查php是否安装了PCNTL库。


 

(2)下载socket:

  sudo apt-get install socket


 

(3)下载MeepoPS的demo:

  https://github.com/lixuancn/MeepoPS/archive/master.zip

  解压传输到linux服务器上。


 (4)进入到解压后的目录

  修改demo-telnet.php的主机地址为127.0.0.1,端口为8080。

  执行:sudo php demo-telnet.php start

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 显示行号进行调试)


 

  

posted @ 2018-07-23 15:41  学知无涯  阅读(292)  评论(0编辑  收藏  举报