定制 xsites/laravel-socket.io 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

xsites/laravel-socket.io

最新稳定版本:v0.1.0

Composer 安装命令:

composer require xsites/laravel-socket.io

包简介

Laravel Socket.io broadcaster

README 文档

README

Installation

Pull this package in through Composer.

    composer require xsites/laravel-socket.io

Laravel 5.* Integration

Add the service provider to your config/app.php file:

    'providers'  => array(

    //...
    Xsites\LaravelSocketIO\Providers\SocketIOServiceProvider::class,

),

Configuration

Add the broadcaster to your config/broadcasting.php file:

    // Set here the new broadcast connection
    'default' => 'socket-io',
    
    //...

    'connections' => [

        // Add additional connection for socket.io broadcaster
        'socket-io' => [
            'driver' => 'socket.io',
            'redis' => [
                //set the redis connection
                'connection' => 'default',
            ],
        ],
        //...

    ],

Usage

See the official documentation https://laravel.com/docs/5.1/events#broadcasting-events

Example

    
    class Test extends Event implements ShouldBroadcast
    {
        /**
         * @var array
         */
        public $data;
    
        /**
         * Create a new event instance.
         *
         * @param mixed $data
         */
        public function __construct($data)
        {
            $this->data = $data;
        }
    
        /**
         * Get the channels the event should be broadcast on.
         *
         * @return array
         */
        public function broadcastOn()
        {
            return ['test-channel-name'];
        }
    }
    
    ...
    //In your BLL
    Event::fire(new Test(['param1' => 'value'1]));
    //
    Event::fire(new Test(123));
    

Contact

Anton Pavlov

统计信息

  • 总下载量: 1.44k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 10
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 9
  • Watchers: 4
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-05-02