laravel5.7 redis socket.io

composer require predis/predis

.env

BROADCAST_DRIVER=redis

config/app.php

取消注释providers下App\Providers\BroadcastServiceProvider::class,

创建文件app/Events/ChatRoom.php

<?php

namespace App\Events;

use Illuminate\Contracts\Broadcasting\ShouldBroadcast;

class ChatRoom implements ShouldBroadcast
{

    public $data;
    private $channels;
    /**
     * Create a new event instance.
     *
     * @return void
     */
    public function __construct($channels, $data)
    {
        //
        $this->channels = $channels;
        $this->data = $data;
    }

    /**
     * Get the channels the event should be broadcast on.
     *
     * @return array
     */
    public function broadcastOn()
    {
        return $this->channels;
    }
}

调用

use Event, App\Events\ChatRoom;

Event::fire(new ChatRoom($channel, ‘data’));

windows下redis

下载https://github.com/MicrosoftArchive/redis/releases

cmd启动redios快捷方式

@echo off
redis-server  redis.windows.conf
@pause

安装Redis Service

redis-server --service-install redis.windows.conf

卸载Redis Service

redis-server --service-uninstall

启动Redis Service

redis-server --service-start

停止Redis Service

redis-server --service-stop

提示:The Windows version of Redis allocates a memory mapped heap for sharing with the forked process used for persistence operations.

是 maxheap 标识有问题,打开配置文件 redis.windows.conf ,搜索# maxheap <bytes>

下面添加maxheap 1024000000