Fix: sse changes
This commit is contained in:
		| @@ -1,18 +1,22 @@ | ||||
| package handlers | ||||
|  | ||||
| import ( | ||||
| 	"fmt" | ||||
| 	"golias/broker" | ||||
| 	"golias/config" | ||||
| 	"golias/pkg/cache" | ||||
| 	"html/template" | ||||
| 	"log/slog" | ||||
| 	"net/http" | ||||
| 	"os" | ||||
| 	"time" | ||||
| ) | ||||
|  | ||||
| var ( | ||||
| 	log      *slog.Logger | ||||
| 	cfg      *config.Config | ||||
| 	memcache cache.Cache | ||||
| 	Notifier *broker.Broker | ||||
| ) | ||||
|  | ||||
| func init() { | ||||
| @@ -22,6 +26,20 @@ func init() { | ||||
| 	})) | ||||
| 	memcache = cache.MemCache | ||||
| 	cfg = config.LoadConfigOrDefault("") | ||||
| 	Notifier = broker.NewBroker() | ||||
| 	go Notifier.Listen() | ||||
| 	ticker := time.NewTicker(2 * time.Second) | ||||
| 	go func() { | ||||
| 		counter := 0 | ||||
| 		for { | ||||
| 			<-ticker.C | ||||
| 			Notifier.Notifier <- broker.NotificationEvent{ | ||||
| 				EventName: "test", | ||||
| 				Payload:   fmt.Sprintf("%v test call of notifier", counter), | ||||
| 			} | ||||
| 			counter++ | ||||
| 		} | ||||
| 	}() | ||||
| } | ||||
|  | ||||
| var roundWords = map[string]string{ | ||||
| @@ -69,10 +87,8 @@ func HandleHome(w http.ResponseWriter, r *http.Request) { | ||||
| 		} | ||||
| 	} | ||||
| 	if fi != nil && fi.Room == nil { | ||||
| 		log.Debug("loading list") | ||||
| 		fi.List = listPublicRooms() | ||||
| 	} | ||||
| 	log.Debug("data debug", "fi", fi) | ||||
| 	if err := tmpl.ExecuteTemplate(w, "base", fi); err != nil { | ||||
| 		log.Error("failed to exec templ;", "error", err, "templ", "base") | ||||
| 	} | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Grail Finder
					Grail Finder