add broadcast to all client and modify lingpong handler

This commit is contained in:
Adrian Zuercher
2025-07-23 09:09:14 +02:00
parent 5e1e4b9daf
commit 8be5c80a22
2 changed files with 40 additions and 66 deletions

View File

@@ -17,6 +17,12 @@ type ClientHandler struct {
Clients models.Clients
}
func SendBroadcast(msg []byte) {
for _, c := range models.Broadcast {
c.SendResponse(msg)
}
}
// initaiates new conections with client map
func NewConnectionHandler() *ClientHandler {
return &ClientHandler{
@@ -41,7 +47,6 @@ func (cH *ClientHandler) ConnectNewClient(id string, c *gin.Context) (client *mo
cH.Lock()
cH.Clients[id] = client
cH.Unlock()
return client, nil
}