Fix: show color; add bot [WIP]
This commit is contained in:
@ -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)
|
||||
|
Reference in New Issue
Block a user