'whatever']); echo json_encode($r, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT), PHP_EOL, PHP_EOL; echo "[3] authorize: invalid auth-token\n"; $r = GameWebSocketAuthHelper::authorize(['auth_token' => 'not_existing_token', 'user_token' => 'not_existing_user_token']); echo json_encode($r, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT), PHP_EOL, PHP_EOL; echo "[4] authorize: invalid admin_ws_token bypass\n"; $r = GameWebSocketAuthHelper::authorize(['admin_ws_token' => 'no_such_admin_token_xxxxxx']); echo json_encode($r, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT), PHP_EOL, PHP_EOL; echo "[5] issue + validate admin_ws_token\n"; $issued = GameWebSocketAuthHelper::issueAdminWsToken(99, 60); echo 'issued: ', json_encode($issued, JSON_UNESCAPED_UNICODE), PHP_EOL; if (($issued['token'] ?? '') !== '') { $r = GameWebSocketAuthHelper::authorize(['admin_ws_token' => $issued['token']]); echo 'authorize ok with issued token: ', json_encode($r, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT), PHP_EOL; } else { echo "WARN: issueAdminWsToken returned empty (Redis 不可用?)\n"; } echo PHP_EOL; echo "[6] SubscriptionRegistry\n"; GameWebSocketSubscriptionRegistry::reset(); GameWebSocketSubscriptionRegistry::registerConnection(10, 14, '127.0.0.1'); GameWebSocketSubscriptionRegistry::registerConnection(11, 0, '127.0.0.1'); $t1 = GameWebSocketSubscriptionRegistry::replaceSubscriptions(10, ['bet.win', 'period.opened', 'period.opened', '', ' ', 'bet.win']); $t2 = GameWebSocketSubscriptionRegistry::replaceSubscriptions(11, ['admin.live.snapshot', 'period.opened']); echo 'cid=10 topics=', json_encode($t1), PHP_EOL; echo 'cid=11 topics=', json_encode($t2), PHP_EOL; echo 'period.opened subscribers=', json_encode(GameWebSocketSubscriptionRegistry::connectionsForTopic('period.opened')), PHP_EOL; echo 'bet.win subscribers=', json_encode(GameWebSocketSubscriptionRegistry::connectionsForTopic('bet.win')), PHP_EOL; echo 'admin.live.snapshot subscribers=', json_encode(GameWebSocketSubscriptionRegistry::connectionsForTopic('admin.live.snapshot')), PHP_EOL; GameWebSocketSubscriptionRegistry::unregisterConnection(10); echo 'after unregister(10), bet.win subscribers=', json_encode(GameWebSocketSubscriptionRegistry::connectionsForTopic('bet.win')), PHP_EOL; echo 'after unregister(10), period.opened subscribers=', json_encode(GameWebSocketSubscriptionRegistry::connectionsForTopic('period.opened')), PHP_EOL; echo 'remaining connection count=', GameWebSocketSubscriptionRegistry::connectionCount(), PHP_EOL; echo "\nALL DONE\n";