<?php
declare (strict_types = 1);

namespace app\listener\space;


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

class EndBet
{
    /**
     * 事件监听处理
     *
     * @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'];
            EndBetService::endBet($numberTabId,$tableInfo);
        }else{
            $ws->emit('endBet', ['status' => false, 'msg' => $res['msg']]);
        }
    }
}
