百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
J

jegarn

> 编程语言
开源

基于 Swoole、Redis 和 msgpack 的聊天系统

175 stars0 点赞0 次浏览
访问官网GitHub

工具介绍

基于 Swoole、Redis 和 msgpack 的聊天系统

Jegarn

A high performance chat system, based on swoole, redis and msgpack. Integrated authorization, chat, groupchat, chatroom and offline storage.

And client-sdk for iOS, Android, JS, and PHP are provided.

Website: https://jegarn.com

@Deprecated

This project has been moved to https://github.com/jegarn.

Support SDKs and Demos

  • iOS SDK
  • Android SDK
  • JS SDK
  • PHP SDK

We also build some applications for showing that how to use those SDKs.

Visit the WebApp Demo, and download the Source Code.

Download Android APP, and download the Source Code.

Download the iOS Project, and run it by Simulator or your iPhone.

Demos Functions:

  1. register and multi accounts login
  2. add friends and chat with friends
  3. create chat group and chat with every member
  4. create chat room and chat with every online people
  5. a always online robot "Counter" for sending a number to everybody

Requirements

  • PHP 5.3.10 or later
  • Swoole 1.7.20 or newer
  • Msgpack 0.5.7
  • Redis 2.8.22

And for demo chat system "minions", it requires:

  • yaf 2.3.5
  • mysql 5.6.26
  • nginx 1.8.0

Installation

bash
wget http://pecl.php.net/get/swoole-1.7.20.tgz
tar -zvxf swoole-1.7.20.tgz 
cd swoole-1.7.20
phpize
./configure --enable-openssl
make && make install
echo "extension=swoole.so" > /etc/php.d/swoole.ini

pecl install msgpack
yum -y install redis

for more details, see INSTALL.md.

Tutorial

Start Server

start a tcp server

$ php server.php 192.168.1.2 9501

start another tcp server

$ php server.php 192.168.1.2 9502

start a websocket server

$ php webserver.php 192.168.1.2 9503

all server use same cache can communicate with each other, and they form a cluster.

Start Client

$ php robot_counter.php

Configuration

// cache server to storage users and messages
'cache'       => [
    'host'     => '192.168.1.2',
    'port'     => 6379,
    'timeout'  => 0.0,
    'password' => null
],
// server config, same as configuration of swoole
'server'      => [
    'host'          => '192.168.199.243',
    'port'          => 9501,
    'worker_num'    => 4,
    'dispatch_mode' => 2,
    'log_file'      => __DIR__ . '/../logs/server_swoole.log',
    'daemonize'     => 1,
    'ssl_cert_file' => __DIR__ . '/ssl.crt',
    'ssl_key_file' => __DIR__ . '/ssl.key'
],
// listeners, you can choose your own packet listeners
'listener' => [
    'jegarn\listener\AuthPacketListener', // always add to first, not authorized user would do nothing
    'jegarn\listener\NotificationPacketListener',
    'jegarn\listener\ChatPacketListener',
    'jegarn\listener\GroupChatPacketListener',
    'jegarn\listener\ChatroomPacketListener'
]

Contribution

Thank you very much because of your contribution, and I believe we can make jegarn better. Some ways available:

  • contribute your code via Pull Request
  • write down your Issues
  • make the Wiki complete

License

Apache License Version 2.0

Issues· 1 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

PHP

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言