pridanie pocty online/available hracov
This commit is contained in:
1 parent
04185a0d97
commit
18ae869ee8
7 files changed
+153
-28
No files matched your search
@@ -3,11 +3,11 @@ import { useGameStore } from '../store/gameStore';
|
||||
import type {
|
||||
Account,
|
||||
GameDetail,
|
||||
GameInfo,
|
||||
GameStatusPayload,
|
||||
Hand,
|
||||
HistoryGame,
|
||||
MyPlayer,
|
||||
OnlineCountPayload,
|
||||
Registration,
|
||||
} from '../types';
|
||||
|
||||
@@ -29,6 +29,9 @@ export const emit = {
|
||||
confirmAccount: (username: string, code: string) =>
|
||||
socket.emit('confirm_account', username, code),
|
||||
login: (username: string, code: string) => socket.emit('login', username, code),
|
||||
// De-authenticates this connection server-side (no disconnect/reconnect --
|
||||
// see the "logout" handler comment in api/__init__.py for why).
|
||||
logout: () => socket.emit('logout'),
|
||||
// history
|
||||
getPlayerHistory: () => socket.emit('get_player_history'),
|
||||
getGameDetail: (gid: string) => socket.emit('get_game_detail', gid),
|
||||
@@ -64,8 +67,11 @@ export const emit = {
|
||||
};
|
||||
|
||||
export function setupSocketListeners() {
|
||||
socket.on('get_games', ({ games }: { games: GameInfo[] }) => {
|
||||
socket.on('get_games', ({ games, online_count, available_count }: OnlineCountPayload) => {
|
||||
useGameStore.getState().setGames(games);
|
||||
if (typeof online_count === 'number') useGameStore.getState().setOnlineCount(online_count);
|
||||
if (typeof available_count === 'number')
|
||||
useGameStore.getState().setAvailableCount(available_count);
|
||||
});
|
||||
|
||||
// Registration step 1: server returns the otpauth URI to render as a QR code.
|
||||
|
||||
Reference in new issue
Block a user