diff --git a/app/web_conn.go b/app/web_conn.go index c4919a6e9b..99a93267d2 100644 --- a/app/web_conn.go +++ b/app/web_conn.go @@ -291,10 +291,10 @@ func (wc *WebConn) IsAuthenticated() bool { return true } -func (wc *WebConn) SendHello() { +func (wc *WebConn) createHelloMessage() *model.WebSocketEvent { msg := model.NewWebSocketEvent(model.WEBSOCKET_EVENT_HELLO, "", "", wc.UserId, nil) msg.Add("server_version", fmt.Sprintf("%v.%v.%v.%v", model.CurrentVersion, model.BuildNumber, wc.App.ClientConfigHash(), wc.App.License() != nil)) - wc.Send <- msg + return msg } func (wc *WebConn) shouldSendEventToGuest(msg *model.WebSocketEvent) bool { diff --git a/app/web_hub.go b/app/web_hub.go index 53ecc64965..38c5b475f0 100644 --- a/app/web_hub.go +++ b/app/web_hub.go @@ -339,10 +339,6 @@ func (h *Hub) Register(webConn *WebConn) { case h.register <- webConn: case <-h.didStop: } - - if webConn.IsAuthenticated() { - webConn.SendHello() - } } func (h *Hub) Unregister(webConn *WebConn) { @@ -410,6 +406,9 @@ func (h *Hub) Start() { case webCon := <-h.register: connections.Add(webCon) atomic.StoreInt64(&h.connectionCount, int64(len(connections.All()))) + if webCon.IsAuthenticated() { + webCon.Send <- webCon.createHelloMessage() + } case webCon := <-h.unregister: connections.Remove(webCon) atomic.StoreInt64(&h.connectionCount, int64(len(connections.All())))