<?php
declare (strict_types = 1);

namespace app\listener\space;

use app\services\process\StartRobService;
use freedom\utils\SocketSession;
use think\swoole\Websocket;

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