源码描述:
这个也测试过了,但是兼容性有问题,可以自行修复。
测试建议使用火狐或者Google Chrome浏览器,不然可能会出现问题。架设略有难度,小白勿试,不要说什么没数据库,。。。。那只能说你是小白。。。安装自动创建
sl-im 是基于 Swoft 微服务协程框架和 Layim 网页聊天系统 所开发出来的聊天室。
功能
- 登录注册(Http)
- 单点登录(Websocket)
- 私聊(Websocket)
- 群聊(Websocket)
- 在线人数(Websocket)
- 获取未读消息(Websocket)
- 好友在线状态(Websocket)
- 好友 查找 添加 同意 拒绝(Http+Websocket)
- 群 创建 查找 添加 同意 拒绝(Http+Websocket)
- 点对点视频聊天(WebRtc+Websocket)
- 聊天记录存储
- 心跳检测
- 消息重发
- 断线重连
- 发送图片及文件
环境:
PHP 7.1+
Swoole 4.3.4+
Composer
Swoft >= 2.0.8
部署方式
Composer
composer update
bean
app/bean.php
'db' => [
'class' => Database::class,
'dsn' => 'mysql:dbname=im;host=127.0.0.1:3306',
'username' => 'root',
'password' => 'gaobinzhan',
'charset' => 'utf8mb4',
],
'db.pool' => [
'class' => \Swoft\Db\Pool::class,
'database' => bean('db'),
'minActive' => 5, // 自己调下连接池大小
'maxActive' => 10
],
数据表迁移
php bin/swoft mig:up
env配置
vim .env # basic APP_DEBUG=0 SWOFT_DEBUG=0 # more ... APP_HOST=https://im.gaobinzhan.com/ WS_URL=wss://im.gaobinzhan.com/im WEB_RTC_URL=wss://im.gaobinzhan.com/video # 是否开启静态处理 这里我关了 让nginx去处理 ENABLE_STATIC_HANDLER=false # swoole v4.4.0以下版本, 此处必须为绝对路径 DOCUMENT_ROOT=/data/wwwroot/IM/public
nginx配置
server{
listen 80
server_name im.xx.com
301 https://}
server{
listen 443 ssl;
root /data/wwwroot/IM/public/;
add_header Strict-Transport-Security "max-age=31536000";
server_name im.gaobinzhan.com;
access_log /data/wwwlog/im-gaobinzhan-com.access.log;
error_log /data/wwwlog/im-gaobinzhan-com.error.log;
client_max_body_size 100m;
ssl_certificate /etc/nginx/ssl/full_chain.pem;
ssl_certificate_key /etc/nginx/ssl/private.key;
ssl_session_timeout 5m;
ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
location / {
proxy_pass http://127.0.0.1:9091;
proxy_set_header Host $host:$server_port;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Real-PORT $remote_port;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /upload {
root /data/wwwroot/IM/public;
}
location /im {
proxy_pass http://127.0.0.1:9091;
proxy_http_version 1.1;
proxy_read_timeout 3600s;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location /video {
proxy_pass http://127.0.0.1:9091;
proxy_http_version 1.1;
proxy_read_timeout 3600s;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
location ~ .*\.(js|ico|css|ttf|woff|woff2|png|jpg|jpeg|svg|gif|htm)$ {
root /data/wwwroot/IM/public;
}
}
Start
挂起
php bin/swoft ws:start
守护进程化
php bin/swoft ws:start -d



声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。


