Frontend — чистый HTML/CSS/JS без сборки (резюме, проекты, игра-заглушки). Gameserver — C++ на uWebSockets (CMake FetchContent), протокол hello/lobby.list_rooms/error проверен end-to-end.
22 lines
756 B
JavaScript
22 lines
756 B
JavaScript
// TODO: полноценный UI лобби (список/создание/присоединение комнат) — этап 3.
|
|
// Пока — проверка связки клиент <-> gameserver (hello -> lobby.list_rooms).
|
|
import { Network, ServerMessage } from './network.js';
|
|
|
|
export function connectAndProbe() {
|
|
const net = new Network();
|
|
|
|
net.on('_open', () => net.hello('cacto'));
|
|
net.on(ServerMessage.HELLO_ACK, () => {
|
|
console.log('[gameserver] hello.ack received');
|
|
net.listRooms();
|
|
});
|
|
net.on(ServerMessage.LOBBY_ROOMS, (payload) => {
|
|
console.log('[gameserver] rooms:', payload.rooms);
|
|
});
|
|
net.on(ServerMessage.ERROR, (payload) => {
|
|
console.error('[gameserver] error:', payload);
|
|
});
|
|
|
|
return net;
|
|
}
|