* @copyright walkor * @link http://www.workerman.net/ * @license http://www.opensource.org/licenses/mit-license.php MIT License */ /** * 用于检测业务代码死循环或者长时间阻塞等问题 * 如果发现业务卡死,可以将下面declare打开(去掉//注释),并执行php start.php reload * 然后观察一段时间workerman.log看是否有process_timeout异常 */ //declare(ticks=1); /** * 聊天主逻辑 * 主要是处理 onMessage onClose */ use \GatewayWorker\Lib\Gateway; use \GatewayWorker\Lib\DbConnection; class Events { public static function onWorkerStart(){ /*global $db; $my_config = array( 'host' => '127.0.0.1', 'port' => '3306', 'user' => 'youeryuan_online', 'password' => 'XwXXAFbp8kaYsLKF_1', 'dbname' => 'youeryuan_online', 'charset' => 'utf8', ); $db = new DbConnection($my_config);*/ } /** * 有消息时 * @param int $client_id * @param mixed $message */ public static function onMessage($client_id, $message) { $hex = []; $receiver = ''; $nfcid = ''; for($i=0; $i'logout', 'from_client_id'=>$client_id, 'from_client_name'=>$_SESSION['client_name'], 'time'=>date('Y-m-d H:i:s')); Gateway::sendToGroup($room_id, json_encode($new_message)); }*/ } }