From 2ad7ad7a8fb234fe626f5335f5811d68128a40b2 Mon Sep 17 00:00:00 2001 From: Ian Gulliver Date: Fri, 11 Mar 2016 12:06:32 -0800 Subject: [PATCH] Keep the greeting around and push it to new clients --- sinks/adsb-ws/hub.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/sinks/adsb-ws/hub.go b/sinks/adsb-ws/hub.go index 1e2f0af..f7239bc 100644 --- a/sinks/adsb-ws/hub.go +++ b/sinks/adsb-ws/hub.go @@ -5,6 +5,7 @@ type hub struct { broadcast chan []byte register chan *connection unregister chan *connection + greeting []byte } var h = hub{ @@ -19,6 +20,7 @@ func (h *hub) run() { select { case c := <-h.register: h.connections[c] = true + c.send <- h.greeting case c := <-h.unregister: _, ok := h.connections[c] @@ -28,6 +30,9 @@ func (h *hub) run() { } case m := <-h.broadcast: + if len(h.greeting) == 0 { + h.greeting = m + } for c := range h.connections { select { case c.send <- m: