Fix: show color; add bot [WIP]

This commit is contained in:
Grail Finder
2025-05-20 13:10:09 +03:00
parent 24f940f175
commit 2342c56aed
11 changed files with 267 additions and 36 deletions

View File

@ -39,29 +39,13 @@ func NewBroker() (broker *Broker) {
}
}
// func (broker *Broker) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// w.Header().Set("Content-Type", "text/event-stream")
// w.Header().Set("Cache-Control", "no-cache")
// w.Header().Set("Connection", "keep-alive")
// w.Header().Set("Access-Control-Allow-Origin", "*")
// // Each connection registers its own message channel with the Broker's connections registry
// messageChan := make(NotifierChan)
// // Signal the broker that we have a new connection
// broker.newClients <- messageChan
// // Remove this client from the map of connected clients
// // when this handler exits.
// defer func() {
// broker.closingClients <- messageChan
// }()
// // c.Stream(func(w io.Writer) bool {
// for {
// // Emit Server Sent Events compatible
// event := <-messageChan
// fmt.Fprintf(w, "event:%s; data:%s\n", event.EventName, event.Payload)
// // c.SSEvent(event.EventName, event.Payload)
// w.(http.Flusher).Flush()
// }
// }
var Notifier *Broker
// for use in different packages
func init() {
Notifier = NewBroker()
go Notifier.Listen()
}
func (broker *Broker) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// Headers (keep these as-is)