简单的聊天室功能,需要服务器安装php swoole扩展。
基于php扩展swoole
开发。
代码自swoole官方demo。
通过websocket通信.请勿使用IE家族浏览器访问
codepen.io
server
{
listen 80;
#listen [::]:80;
server_name chat.hhtjim.com;
#index index.html index.htm index.php default.html default.htm default.php;
root /home/wwwroot/chat.hhtjim.com;
#include other.conf;
#error_page 404 /404.html;
#include enable-php.conf;
# 访问 ws://chat.hhtjim.com/ 下的内容将被反向代理到http://127.0.0.1:9501
location /
{
proxy_pass http://127.0.0.1:9501;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
...
}