Marco
eb946b4267
1. Use maintained websocket framework 2. Introduce function that allows to register a websocket connection per player
22 lines
281 B
Go
22 lines
281 B
Go
package server
|
|
|
|
import (
|
|
"github.com/google/uuid"
|
|
"nhooyr.io/websocket"
|
|
)
|
|
|
|
type Player struct {
|
|
Uuid uuid.UUID
|
|
Conn websocket.Conn
|
|
}
|
|
|
|
type PlayerInfo struct {
|
|
PlayerID uuid.UUID `json:"playerID"`
|
|
}
|
|
|
|
func NewPlayer(uuid uuid.UUID) *Player {
|
|
return &Player{
|
|
Uuid: uuid,
|
|
}
|
|
}
|