package cache

import (
	"jannex/robot-control-manager/modules/structs"
	"sync"

	"github.com/google/uuid"
)

var sseClients = make(map[uuid.UUID]structs.SSEClient)
var sMu sync.RWMutex

func AddSSEClient(client structs.SSEClient) {
	sMu.Lock()
	defer sMu.Unlock()

	sseClients[uuid.New()] = client
}

func DeleteSSEClient(id uuid.UUID) {
	sMu.Lock()
	defer sMu.Unlock()

	delete(sseClients, id)
}

func GetSSEClients() map[uuid.UUID]structs.SSEClient {
	sMu.RLock()
	defer sMu.RUnlock()

	return sseClients
}
