定制 own3d/socket 二次开发

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

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

own3d/socket

最新稳定版本:1.2.1

Composer 安装命令:

composer require own3d/socket

包简介

OWN3D Socket Client

README 文档

README

Installation

composer require own3d/socket

Configuration

Add the own3d-socket configuration within the config/services.php config file.

'own3d-socket' => [
    'username' => env('OWN3D_SOCKET_USERNAME', 'own3d-socket'),
    'password' => env('OWN3D_SOCKET_PASSWORD')
    'secret' => env('OWN3D_SOCKET_SECRET'),
],

Configure as Laravel Broadcaster

OWN3D Socket can be also used as Laravel Broadcaster. Important is, all events MUST prefixed with your own3d/id client id. This will be already done in the broadcaster and can be configured with the room_prefix.

Add the own3d-socket configuration within the config/broadcasting.php config file.

'own3d-socket' => [
    'driver' => 'own3d-socket',
    'room_prefix' => env('OWN3D_ID_KEY'),
],

On the client side, use:

import {io} from 'socket.io-client';

const socket = io('https://socket-hel1-1.own3d.dev', {
    withCredentials: true,
});

socket
    .on('connect', () => {
        console.log('Socket connected.', socket.id);
        socket.emit('room', '<room-prefix>.<channel-name>');
    })
    .on('App\\Events\\ExampleEvent', (e) => {
        // e contains additional event data
    });
namespace App\Events;

use Illuminate\Broadcasting\Channel;
use Illuminate\Broadcasting\InteractsWithSockets;
use Illuminate\Contracts\Broadcasting\ShouldBroadcast;
use Illuminate\Foundation\Events\Dispatchable;
use Illuminate\Queue\SerializesModels;

class ExampleEvent implements ShouldBroadcast
{
    use Dispatchable, InteractsWithSockets, SerializesModels;

    private string $userId;
    
    /**
     * Get the channels the event should broadcast on.
     *
     * @return Channel|array
     */
    public function broadcastOn()
    {
        return new Channel('channel-name');
    }
}

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: proprietary
  • 更新时间: 2023-01-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固