12 lines
888 B
Plaintext
12 lines
888 B
Plaintext
# Task ID: 9
|
|
# Title: WebSocket Server & Basic Messaging
|
|
# Status: pending
|
|
# Dependencies: 1
|
|
# Priority: high
|
|
# Description: Set up the WebSocket server using Fastify's WebSocket plugin. Define a basic message protocol and implement initial message handling for connection, disconnection, and a simple 'ping-pong' heartbeat mechanism.
|
|
# Details:
|
|
Integrate `@fastify/websocket` plugin. Design a generic `GameMessage` interface with `type`, `roomCode`, `userId`, `data`, `timestamp`, `sequence`. Implement handlers for `connection` and `disconnection` events. Set up a heartbeat mechanism to detect inactive clients (e.g., every 30 seconds).
|
|
|
|
# Test Strategy:
|
|
Use a WebSocket client (e.g., Postman, browser console) to connect, send messages, and disconnect. Verify server logs for connection/disconnection events. Test heartbeat by letting a client idle and observing server-side timeout.
|