Git Product home page Git Product logo

xielei / swoole-worker Goto Github PK

View Code? Open in Web Editor NEW
132.0 5.0 26.0 425 KB

SwooleWorker是基于swoole开发的一款分布式长连接开发框架。常驻内存,协程,高性能高并发;分布式部署,横向扩容,使得能支持庞大的连接数;无感知安全重启,无缝升级代码;接口丰富,支持单个发送,分组发送,群发广播等接口。可广泛应用于云计算、物联网(IOT)、车联网、智能家居、网络游戏等领域。

Home Page: https://swoole.plus/

License: Apache License 2.0

PHP 100.00%
swoole swoole-worker swoole-extension

swoole-worker's Introduction

介绍

SwooleWorker是基于swoole开发的一款分布式长连接开发框架。常驻内存,协程,高性能高并发;分布式部署,横向扩容,使得能支持庞大的连接数;无感知安全重启,无缝升级代码;接口丰富,支持单个发送,分组发送,群发广播等接口。可广泛应用于云计算、物联网(IOT)、车联网、智能家居、网络游戏等领域。

【官方网站】 【开发文档】

架构图

适用对象

SwooleWorker是一个长链接框架,适用于需要长期保持连接的服务

适用于:

  • 物联网
  • 车联网
  • 智能家居
  • 网络游戏
  • 移动推送
  • IM

不适用于:

  • 传统web项目

安装

composer require xielei/swoole-worker

接口

接口 参数 返回值
sendToClient string $client, string $message
sendToUid string $uid, string $message, array $without_client_list = []
sendToGroup string $group, string $message, array $without_client_list = []
sendToAll string $message, array $without_client_list = []
isOnline string $client
isUidOnline string $uid bool
getClientListByGroup string $group, string $prev_client = null iterable
getClientCount int
getClientCountByGroup string $group int
getClientList string $prev_client = null iterable
getClientListByUid string $uid, string $prev_client = null iterable
getClientInfo string $client, int $type = 255 array
getUidListByGroup string $group, bool $unique = true iterable
getUidList bool $unique = true iterable
getUidCount float $unique_percent = null int
getGroupList bool $unique = true iterable
getUidCountByGroup string $group int
closeClient string $client, bool $force = false
bindUid string $client, string $uid
unBindUid string $client
joinGroup string $client, string $group
leaveGroup string $client, string $group
unGroup string $group
setSession string $client, array $session
updateSession string $client, array $session
deleteSession string $client
getSession string $client ?array

swoole-worker's People

Contributors

xielei avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

swoole-worker's Issues

gateway.php启动后 register.php报错 请问是什么原因?

Fatal error: Uncaught TypeError: Argument 2 passed to Xielei\Swoole\Service::{closure}() must be an instance of Swoole\Server\Event, int given in /mnt/d/linuxdev/swooler/vendor/xielei/swoole-worker/src/reload/register.php:27
Stack trace:
#0 [internal function]: Xielei\Swoole\Service->{closure}()
#1 /mnt/d/linuxdev/swooler/vendor/xielei/swoole-worker/src/Service.php(239): call_user_func()
#2 /mnt/d/linuxdev/swooler/vendor/xielei/swoole-worker/src/Service.php(207): Xielei\Swoole\Service->emit()
#3 {main}
thrown in /mnt/d/linuxdev/swooler/vendor/xielei/swoole-worker/src/reload/register.php on line 27

请问下worker中如何实现类似controller这样的结构

看了官网的demo,所有的业务逻辑都是写在worker.php里面,这样会导致业务逻辑很复杂,我想的是能不能我自己实现一个logic逻辑来处理不同的业务,在里面可以使用worker启动时候初始化的redis和db连接,而不是重复实例化。

启动worker文件 显示这样的错误#0 Swoole\Server\Helper::checkOptions()

the service is running with daemonize

#0 Swoole\Server\Helper::checkOptions()
#1 Swoole\Server\Port->set()
#2 Swoole\Server->set() called at [/www/test/vendor/xielei/swoole-worker/src/Service.php:212]
#3 Xielei\Swoole\Service->startServer() called at [/www/test/vendor/xielei/swoole-worker/src/Service.php:73]
#4 Xielei\Swoole\Service->Xielei\Swoole{closure}()
#5 call_user_func() called at [/www/test/vendor/xielei/swoole-worker/src/Cli.php:99

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.