Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ServeWs ¶
func ServeWs(hub *Hub, w http.ResponseWriter, r *http.Request, config util.Config, store db.Store, gameService *gameservice.GameService, mq *MessageQueue, tokenMaker token.Maker)
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a single chatting user.
func NewClient ¶
func NewClient(ctx context.Context, hub *Hub, conn *websocket.Conn, userID int64, store db.Store, gameService *gameservice.GameService, mq *MessageQueue, broadcastChan chan<- []byte, gameID int64, playerGameID int64) *Client
NewClient initializes a new client and sets up message handlers
type DrawCardPayload ¶
type DrawCardPayload struct { GameID int64 `json:"game_id"` PlayerGameID int64 `json:"player_game_id"` PlayerNumber int32 `json:"player_number"` }
DrawCardPayload matches the structure expected in the DrawCardRequest message
type EndTurnPayload ¶
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
Hub maintains the set of active clients and broadcasts messages to the clients.
func (*Hub) HandleGameEvents ¶
func (h *Hub) HandleGameEvents()
type MessageQueue ¶
type MessageQueue struct {
// contains filtered or unexported fields
}
func NewMessageQueue ¶
func NewMessageQueue(size int) *MessageQueue
func (*MessageQueue) Enqueue ¶
func (mq *MessageQueue) Enqueue(message []byte)
func (*MessageQueue) StartProcessing ¶
func (mq *MessageQueue) StartProcessing(hub *Hub)
type PlayDessertPayload ¶
type PlayDessertPayload struct { GameID int64 `json:"game_id"` PlayerGameID int64 `json:"player_game_id"` DessertName string `json:"dessert_name"` CardIDs []int64 `json:"card_ids"` }
PlayDessertPayload mirrors the PlayDessertRequest from gRPC
type PlayDessertResponseJSON ¶
type PlayDessertResponseJSON struct { DessertPlayedId int64 `json:"dessert_played_id"` PlayerGame *PlayerGameJSON `json:"player_game"` GameOver bool `json:"game_over"` }
Custom struct that mirrors pb.PlayDessertResponse but is safe for marshaling
type PlayerGameJSON ¶
type SpecialCardPayload ¶
type WebSocketMessage ¶
type WebSocketMessage struct { Type string `json:"type"` Data json.RawMessage `json:"data"` }
Click to show internal directories.
Click to hide internal directories.