<?php
declare (strict_types = 1);

namespace app\listener\space;


use app\services\process\StartBetService;
use freedom\utils\SocketSession;
use think\swoole\WebSocket;

class StartBet
{
    /**
     * 事件监听处理
     *
     * @return void
     */
    public function handle(array $event, WebSocket $ws)
    {
        $res = SocketSession::preliminaryCheck($event,'space');
        if ($res['status'] == true){
            $numberTabId = intval($event['number_tab_id']);
            $tableInfo = $res['data'];
            StartBetService::startBet($numberTabId,$tableInfo);
        }else{
            $ws->emit('startBet', ['status' => false, 'msg' => $res['msg']]);
        }
    }
}
