swoole worker

Overview

SwooleWorker

SwooleWorker is a distributed long connection development framework based on Swoole4.

【Github】 【HomePage】

Manual

【ENGLISH】 【简体中文】

Usage scenarios

  1. Push
  2. IOT
  3. IM
  4. Games
  5. Others

Install

composer require xielei/swoole-worker

System structure

structure

Api preview

  • sendToClient(string $client, string $message)
  • sendToUid(string $uid, string $message)
  • 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
  • sendToAddressListAndRecv(array $items, float $timeout = 1): array
  • sendToAddressAndRecv(array $address, string $buffer, float $timeout = 1): string
  • sendToAddress(array $address, string $buffer, $timeout = 1)

If the above interfaces do not meet the requirements, custom commands are also supported~

You might also like...
Library for Open Swoole extension

Open Swoole Library This library works with Open Swoole since release version v4.7.1. WIP Table of Contents How to Contribute Code Requirements Develo

Hyperf instant messaging program based on swoole framework
Hyperf instant messaging program based on swoole framework

Hyperf instant messaging program based on swoole framework

Redis watcher for PHP-Casbin in Swoole.

Redis watcher for PHP-Casbin in Swoole Redis watcher for PHP-Casbin in Swoole , Casbin is a powerful and efficient open-source access control library.

Socks5 proxy server written in Swoole PHP

php-socks This is a Socks5 proxy server implementation built with PHP & Swoole. To start the proxy server, clone this repo, run composer install to in

LaravelS is an out-of-the-box adapter between Swoole and Laravel/Lumen.
LaravelS is an out-of-the-box adapter between Swoole and Laravel/Lumen.

🚀 LaravelS is an out-of-the-box adapter between Swoole and Laravel/Lumen.

DoraRPC is an RPC For the PHP MicroService by The Swoole

Dora RPC 简介(Introduction) Dora RPC 是一款基础于Swoole定长包头通讯协议的最精简的RPC, 用于复杂项目前后端分离,分离后项目都通过API工作可更好的跟踪、升级、维护及管理。 问题提交: Issue For complex projects separation

Hprose asynchronous client & standalone server based on swoole
Hprose asynchronous client & standalone server based on swoole

Hprose for Swoole Introduction Hprose is a High Performance Remote Object Service Engine. It is a modern, lightweight, cross-language, cross-platform,

PHP Kafka client is used in PHP-FPM and Swoole. PHP Kafka client supports 50 APIs, which might be one that supports the most message types ever.

longlang/phpkafka Introduction English | 简体中文 PHP Kafka client is used in PHP-FPM and Swoole. The communication protocol is based on the JSON file in

This package provides a high performance HTTP server to speed up your Laravel/Lumen application based on Swoole.
This package provides a high performance HTTP server to speed up your Laravel/Lumen application based on Swoole.

This package provides a high performance HTTP server to speed up your Laravel/Lumen application based on Swoole.

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

    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

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

    启动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

    opened by linxianfu 2
  • 启动之后,连接WS就提示这个错误protocol decode failure! buffer:

    启动之后,连接WS就提示这个错误protocol decode failure! buffer:

    Fatal error: Uncaught exception 'Exception' with message: protocol decode failure! buffer: thrown in /www/test/vendor/xielei/swoole-worker/src/Protocol.php on line 39 Trace: #0 /www/test/vendor/xielei/swoole-worker/src/Worker.php(78): Xielei\Swoole\Protocol::decode('')

    opened by linxianfu 1
Releases(2.0.1)
  • 2.0.1(Dec 20, 2021)

  • 2.0.0(Aug 22, 2021)

    升级指导

    2.x主要是对配置项做了优化,配置项修改即生效,无须重启~

    这样做的好处是在正式项目中,需要变更配置的时候,无须重启服务,做到用户无感知~

    具体可以看脚手架【https://github.com/xielei/project】项目,每条均有详细注明

    Register

    • debugregister_secretreload_watch等参数放入配置文件

    Gateway

    • debugregister_secretreload_watch等放入配置文件
    • 新增自定义命令配置项command_extra_list,原来的自定义命令方式废弃
    • 新增路由配置项router,原来的路由设置方式废弃
    • 限流相关配置项throttlethrottle_intervalthrottle_timesthrottle_close放入配置文件

    Worker

    • debugregister_secretreload_watch等参数放入配置文件
    • worker_filetask_file等参数放入配置文件
    • 新增tag_list配置项,设置worker的标签,在gateway中可以根据此标签增强路由分配
    Source code(tar.gz)
    Source code(zip)
  • 1.0.10(Aug 4, 2021)

  • 1.0.9(Jul 31, 2021)

  • 1.0.5(Jun 23, 2021)

Owner
null
💫 Vega is a CLI mode HTTP web framework written in PHP support Swoole, WorkerMan / Vega 是一个用 PHP 编写的 CLI 模式 HTTP 网络框架,支持 Swoole、WorkerMan

Mix Vega 中文 | English Vega is a CLI mode HTTP web framework written in PHP support Swoole, WorkerMan Vega 是一个用 PHP 编写的 CLI 模式 HTTP 网络框架,支持 Swoole、Work

Mix PHP 46 Apr 28, 2022
A easy way to install your basic yii projetc, we have encrypt database password in phpfile, my class with alot funtions to help you encrypt and decrypt and our swoole server install just run ./yii swoole/start and be happy!

Yii 2 Basic Project Template with swoole and Modules Yii 2 Basic Project Template is a skeleton Yii 2 application best for rapidly creating small proj

null 3 Apr 11, 2022
swoole,easyswoole,swoole framework

EasySwoole - A High Performance Swoole Framework EasySwoole is a distributed, persistent memory PHP framework based on the Swoole extension. It was cr

null 4.6k Jan 2, 2023
swoole and golang ipc, use goroutine complete swoole coroutine

swoole and golang ipc demo swoole process module exec go excutable file as sider car, use goroutine complete swoole coroutine hub.php <?php require '

null 2 Apr 17, 2022
TCP Worker Client for RoadRunner 2.0 application server

RoadRunner TCP Plugin RoadRunner is an open-source (MIT licensed) high-performance PHP application server, load balancer, and process manager. It supp

Spiral Scout 8 Nov 26, 2022
一个极简高性能php框架,支持[swoole | php-fpm ]环境

One - 一个极简高性能php框架,支持[swoole | php-fpm ]环境 快 - 即使在php-fpm下也能1ms内响应请求 简单 - 让你重点关心用one做什么,而不是怎么用one 灵活 - 各个组件松耦合,可以灵活搭配使用,使用方法保持一致 原生sql可以和模型关系with搭配使用,

vic 862 Jan 1, 2023
球球大作战(PHP+Swoole)

球球大作战 在线多人H5游戏(H5客户端, 服务端) W A S D 控制 技术栈: PHP7.4+ Swoole4.6(多进程, WebSocket, 共享内存) SpriteJS v3(2D Canvas渲染) 演示Demo 安装: 环境要求:Linux,PHP7.4+(启用Swoole拓展)

Vacant 15 May 9, 2022
基于 swoole 的多进程队列系统,低延时(最低毫秒级)、低资源占用, 支持一键化协程、超时控制、失败重试。可与 laravel thinkphp 等框架配合使用

multi-process-queue 基于swoole的多进程队列系统,manage进程管理子进程,master进程监听队列分发任务,worker进程执行任务, 多进程、低延时(最低毫秒级)、低资源占用。可与 laravel thinkphp 等框架配合使用 版本要求: php>=7.1 swoo

yuntian 55 Dec 12, 2022
🚀 Developing Rocketseat's Next Level Week (NLW#05) Application using PHP/Swoole + Hyperf

Inmana PHP ?? Developing Rocketseat 's Next Level Week (NLW#05) Application using Swoole + Hyperf. This is the app of the Elixir track. I know PHP/Swo

Leo Cavalcante 18 Jun 1, 2022
Simple live support server with PHP Swoole Websocket and Telegram API

Telgraf Simple live support server with PHP Swoole Websocket and Telegram API. Usage Server Setup Clone repository with following command. git clone h

Adem Ali Durmuş 6 Dec 30, 2022