ststc / achilles Goto Github PK
View Code? Open in Web Editor NEW这是一个包含长连接推送、异步任务和http服务的简易框架
这是一个包含长连接推送、异步任务和http服务的简易框架
:)include(./gearman) :)include(./rabbitmq) #-------------------------------------------- 这是一个包含长连接推送、异步任务和http服务的简易框架 并集成了gearman和rabbitmq #-------------------------------------------- 目录结构 bootstrap //普通http服务入口文件,配合nginx使用 backServer //异步http服务器 longConnect //长连接推送服务 console //脚本任务 /assets //img、js、css资源目录 /base/app //基本的类,如控制器类、DB实例类 /base/params //项目的一些配置参数 /base/gearman //后台任务函数库 /controller //具体的控制器 /console //可以跑的脚本 /component //一个功能模块化后可复用的函数集合 /models //每个数据表的模型,关于一个表的CRUD /view //以控制器为文件夹名来组织的视图文件 #-------------------------------------------- 配置参数 redis和mysql的host及port等配置 #-------------------------------------------- 长连接客户端的参数 controler //交由处理的控制器 action //交由处理的方法 sent //0是注册,1是发送 type //one单独推送,group群推送 data[event] //具体的参数[业务标识] data[param] //具体的参数[用户标识][单个推送时才有] 应用实例: 1.直播结束,向所有客户端推送消息,转到下一阶段 2.扫描二维码去支付,支付后获取订单状态自动转跳到其他页面 #-------------------------------------------- 示例 #-------------------------------------------- 长连接demo 打开本地redis 启动长连接服务 php longConnect.php HOST/client/qrcode //扫二维码页面 HOST/client/paid //支付点击页面 HOST/client/show //直播页面 HOST/client/console //直播控制台 #-------------------------------------------- 后台任务demo 启动异步http服务器 php backServer.php HOST:9501/task/demo //后台任务demo 会在achilles库log表里添加一条记录 #-------------------------------------------- 控制台demo[gearman] //启动gearman /usr/local/Cellar/gearman/1.1.18/sbin/gearmand -d //查看所有命令 php console.php //启动worker php console.php Gearman:worker //gearman客户端[显示及反转] php console.php Gearman:client normal something php console.php Gearman:client reverse something #-------------------------------------------- IM示例[rabbitmq] #发送端 @1: /usr/bin/php console.php Rabbitmq:chat uid_1 @3: /usr/bin/php console.php Rabbitmq:chat uid_3 #接收端 /usr/bin/php console.php Rabbitmq:message uid_1 /usr/bin/php console.php Rabbitmq:message uid_2 /usr/bin/php console.php Rabbitmq:message uid_3 /usr/bin/php console.php Rabbitmq:message uid_4 #关系 gid_1 = uid_1 + uid_2 + uid_3 gid_2 = uid_3 + uid_4 #1v1单聊 1给2发消息 @1: [uid_2:msg1] 3给2发消息 @3: [uid_2:msg2] @3: [uid_4:msg3] 2收到1和3的消息 && 4收到3的消息 #群消息 @1: [gid_1:this is group message!] uid2、uid3收到信息,而uid1、uid4没有 #-------------------------------------------- 建表语句 create databases achilles; CREATE TABLE `log` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `desc` varchar(255) DEFAULT NULL, `date` varchar(255) DEFAULT NULL, `time` int(11) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; #-------------------------------------------- nginx配置 server { listen 80; server_name achilles.cn; root /Applications/XAMPP/xamppfiles/htdocs/Achilles; index index.html bootstrap.php; location / { try_files $uri $uri/ /bootstrap.php$is_args$query_string; } location ~ \.php$ { try_files $uri =404; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ .*\.(gif|jpg|jpeg|bmp|png|ico)$ { root /Users/fanzhen/htdocs/Achilles/assets/img; } location ~ .*\.css$ { root /Users/fanzhen/htdocs/Achilles/assets/css; } location ~ .*\.js$ { root /Users/fanzhen/htdocs/Achilles/assets/js; } }
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.