{"repo":"caohao-go/ycsocket","free":true,"listed":false,"github":"https://github.com/caohao-go/ycsocket","clone":"git clone https://github.com/caohao-go/ycsocket.git","description":"基于swoole的socket框架，支持协程版MySQL、Redis连接池，已用于大型RPG游戏服务端","language":"Go","stars":98,"topics":["swoole","coroutine","pool","mysql","redis"],"license":"Apache-2.0","category":"databases-storage","readme_excerpt":"ycsocket 概述 基于 swoole 和 swoole orm 的极度轻量级 websocket 框架，我认为php就应该简单高效，各位可以自己扩展到 TCP/UDP，HTTP。 在ycsocket 中，采用的是全协程化，全池化的数据库、缓存IO，支持重连，对于IO密集型的应用，能够支撑较高并发。 支持 Redis 协程线程池，源码位于 system/RedisPool，支持失败自动重连 支持 MySQL 协程连接池， 源码位于 system/MySQLPool，支持失败自动重连 客户端chat.html是一个聊天窗口，用于发送测试 demo 环境 PHP7.1+ swoole 4.0 以上 swoole orm //一个C语言扩展的ORM，本框架协程数据库需要该扩展支持，https://github.com/swoole/ext-orm 应用场景 大型RPG游戏，纯php解决方案，php + swoole + swoole orm + zephir ，这个游戏的战斗部分完全用 zephir 来实现，转化为 php 扩展，能做到同时兼顾性能和开发效率，（zephir 代码有机会我再开源出来，目前时机不成熟，游戏还比较火热），微信小游戏搜索：\"剑的传说\" 代码结构 请求路由 输入参数为json， 根据 c 和 m 参数，路由到 controller/Game.php 下 verAction 函数。路由逻辑在 Application- run() 方法中， 路由之前，首先会调用 Filter::auth($params) 对参数验签，我们可以在该函数中加入自己的签名验证逻辑。 控制器Controller 所有控制器位于：application/controllers 目录下，继承自SuperController，父类SuperController 的构造函数中会调用$this- init()函数，所以你的控制器如果有初始化任务，请写在 init 函数里。 提供4个返回函数： response error 返回报错信息给自己 response success to all 返回数据给当前所有玩家，例如世界聊天 response success to me 返回数据给自己 response success to uids 返回数据给指定uid，在 server.php ，数据接入的时候，我们会将 uid 绑定到 socket fd 上面去 过滤验签 application/Filter.php ， 在 auth 中写入验签方法，所有接口都会在这里校验， 所有GET、POST等参数放在 $params 里。 加载器 通过 Loader 加载器可以加载业务层，dao层，公共库，日志、配置等对象， Logger 为日志类。 业务层 通过 $this- game service = $this- loader- service('GameService'); 去加载业务层。 Service 继承自 SuperService，在 init() 函数里面实现对象初始化内容。 Dao层 所有与Redis、MySQL等等存储介质打交道的逻辑，最好都放在Dao层， dao对象通过 $this- game dao = $this- loader- dao(\"GameDao\"); 加载。 Dao层继承自 SuperDao，在 init() 函数里面实现对象初始化内容。 SuperDao 提供了许多快速操作数据库的方法，如果你需要用到 SuperDao 的快速操作数据库的","default_branch":null,"files":null,"tree":[],"storefront":"/r/caohao-go","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/caohao-go/ycsocket/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}