承接 jilenloa/echo-socketcluster-broadcast-driver 相关项目开发

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

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

jilenloa/echo-socketcluster-broadcast-driver

Composer 安装命令:

composer require jilenloa/echo-socketcluster-broadcast-driver

包简介

Laravel socketcluster broadcaster. This is compatible with Laravel Echo client

README 文档

README

Build Status Total Downloads

It's supported on PHP 7.1+, Laravel 5.8+

Before you can use this library, you first need to setup a server "echo-socketcluster-server". It works similarly to the default "laravel-echo-server". However, it is installed when you run the vendor:publish command. Find that below.

php artisan vendor:publish --tag=echosocketcluster

Echo Compatible Server using SocketCluster

The echo-socketcluster-server package is created using SocketCluster and it's part of this repo and you can copy it to any folder of your choice. It comes with its own package.json, so you would need to run the npm install command inside the folder afterwards.

For more information on SocketCluster, visit https://socketcluster.io/.

Laravel Installation

Install package using Composer

composer require jilenloa/echo-socketcluster-broadcast-driver:dev-master

Add below to your broadcasting.php file.

'echosocketcluster' => [
    'driver' => 'echosocketcluster',
],

Add this configuration to your .env file. Update the current setting for BROADCAST_DRIVER to the one below

BROADCAST_DRIVER=echosocketcluster #"redis" is also compatible with this broadcast server just like the default laravel-echo

ECHO_SC_HOST=localhost:8001
ECHO_SC_TOKEN=echo-server-token
REDIS_KEY_PREFIX=laravel_ # just like you would set in laravel-echo-server.json
SOCKETCLUSTER_PORT=8001
SOCKETCLUSTER_WS_ENGINE=uws # defaule engine is "ws"
SOCKETCLUSTER_HTTP_TOKEN=echo-server-token

If you have not done this, you can publish the configuration and echo-socketcluster-server files using the command:

php artisan vendor:publish --tag=echosocketcluster

You can then later update the package later using composer:

composer update

Laravel Echo Client

npm install laravel-echo
npm install laravel-echo-connector-socketcluster

Below is a sample use of the Laravel Echo client.

import Echo from "laravel-echo";
import SocketClusterConnector from "laravel-echo-connector-socketcluster";
window.socketClusterClient = require('./socketcluster-client');

let echo = new Echo({
    client: socketClusterClient,
    broadcaster: SocketClusterConnector,
      auth: {
        headers: {
            //add custom headers here, useful for JWT authentication
        },
        hostname: 'localhost:8001', //laravel host to authorize channels. this is sometimes optional
      },
      socketcluster: {
            hostname: 'localhost',
            port: 8001
        }
    });

For more information on laravel-echo visit https://laravel.com/docs/broadcasting.

Finally

  • Before testing, ensure that you have started the echo-socketcluster-server.

If you experience any challenge, don't hesitate to submit an issue here.

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: JavaScript

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-02-09