nya / chat
此包的最新版本(1.0.0)没有可用的许可证信息。
基于swoole的laravel聊天插件
1.0.0
2017-07-28 11:23 UTC
This package is not auto-updated.
Last update: 2024-09-29 05:34:55 UTC
README
依赖
- laravel
- swoole扩展
安装
composer require nya/chat
将命令添加到app/console/Kernel.php
use Nya\Chat\Coo; ... protected $commands = [ Coo::class ];
配置文件config/nya.php
<?php return [ 'host' =>'0.0.0.0', 'port'=>2333, 'class' => 'App\Nya', 'pid_file' => storage_path('/logs/swoole.pid'), 'use_ssl' => false, 'ssl_key_file' => '/data/ssl/vgamer.im/vgamer.im.key', 'ssl_cert_file' => '/data/ssl/vgamer.im/vgamer.im_bundle.crt', 'message' => 'message_', 'open' => 'open', 'close' => 'close', 'type' => 'type', 'data' => 'data' ];
其中message以下都有默认
使用
新建示例类app/Nya.php
<?php namespace App; class Nya{ public function message_say($fd, $type){ $this->nya->push($fd, 'nya?'); } // 非必要 public function open($fd){ $this->nya->push($fd, 'link'); } public function close($fd){ // ... } }
启动聊天服务:php artisan nya start
停止使用stop
前台websocket连接端口2333
,返回 'link'
发送
{ "type": "say", "data": "nyanyanya" }
后台返回'nya?'