<?php
declare (strict_types = 1);

namespace app\listener\space;

use app\services\opening\OpeningRouletteService;
use freedom\utils\SocketSession;
use think\swoole\Websocket;

class OpeningRoulette
{
    /**
     * 事件监听处理
     *
     * @return void
     */
    public function handle(array $event, Websocket $ws)
    {
        $preliminaryCheckRes = SocketSession::preliminaryCheck($event,'space');
        if($preliminaryCheckRes['status'] == true){
            $tableInfo = $preliminaryCheckRes['data'];
            OpeningRouletteService::openingRoulette($event,$tableInfo,$ws);
        }else{
            $ws->emit('openingRoulette', ['status' => false, 'msg' => $preliminaryCheckRes['msg']]);
        }
    }
}
