承接 smart-crowd/centrifuge-broadcaster 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

smart-crowd/centrifuge-broadcaster

最新稳定版本:v1.0

Composer 安装命令:

composer require smart-crowd/centrifuge-broadcaster

包简介

Centrifuge and centrifugo broadcaster for laravel 5.1

README 文档

README

Centrifuge and centrifugo broadcaster for laravel 5.1

Centrifuge is not supported at this time because changes made during the upgrade Centrifugo to 1.0 broken backward compatibility.

If you can not go to Centrifugo, use the package version 0.3.1

Installation

  1. composer require smart-crowd/centrifuge-broadcaster
  2. In config/broadcasting:
    'default' => 'centrifuge',
    'connections' => [
        ...
        'centrifuge' => [
            'driver'          => 'centrifuge',
            'transport'       => 'http', // or redis
            'redisConnection' => 'default', // for redis transport only
            'baseUrl'         => 'http://myapp.exapmle:8000',
            'secret'          => 'f27d79a1-821f-4e3f-47b2-7cb308768c77',
            'topLevelFields'  => [
                /**
                 * to implement
                 * http://fzambia.gitbooks.io/centrifugal/content/mixed/exclude_sender.html
                 * you should pass in payload `centClientId` field
                 */
                'centClientId' => 'client',
            ],
        ]
    ]
  1. Add provider and alias in config/app.php
    'providers' => [
        ...
        SmartCrowd\Centrifuge\CentrifugeServiceProvider::class
    ],
    
    'aliases' => [
        ...
        'Centrifuge' => SmartCrowd\Centrifuge\CentrifugeFacade::class
    ]

Server configuration

http://fzambia.gitbooks.io/centrifugal/content/index.html

Send messages to centrifugo

You should just fire broadcastable event. See http://laravel.com/docs/5.1/events#broadcasting-events. Don't forget, that events are broadcasted into queued jobs, so configure your queues.

Connect from client

Use oficial centrifuge client library https://github.com/centrifugal/centrifuge-js. In your view:

<script src="https://cdn.jsdelivr.net/sockjs/1.0/sockjs.min.js"></script>
<script src="https://rawgit.com/centrifugal/centrifuge-js/master/centrifuge.js"></script>

<script>
    var centrifuge = new Centrifuge({!! json_encode(Centrifuge::getConnection($isSockJS = true)) !!});

    centrifuge.connect();

    centrifuge.on('connect', function() {
        var subscription = centrifuge.subscribe('test-channel', function(message) {
            console.log(message);
        });
    });
</script>

统计信息

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

GitHub 信息

  • Stars: 7
  • Watchers: 3
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-08-13