From d058be25ad93bf6a0c206ac33ed7db07d1479573 Mon Sep 17 00:00:00 2001 From: NikkyAI Date: Fri, 2 Nov 2018 16:35:13 +0100 Subject: Respond with message on connect (api) (#550) fix #549 --- bridge/api/api.go | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'bridge/api') diff --git a/bridge/api/api.go b/bridge/api/api.go index 28c57106..0ccd85b6 100644 --- a/bridge/api/api.go +++ b/bridge/api/api.go @@ -102,6 +102,14 @@ func (b *Api) handleMessages(c echo.Context) error { func (b *Api) handleStream(c echo.Context) error { c.Response().Header().Set(echo.HeaderContentType, echo.MIMEApplicationJSON) c.Response().WriteHeader(http.StatusOK) + greet := config.Message{ + Event:config.EVENT_API_CONNECTED, + Timestamp:time.Now(), + } + if err := json.NewEncoder(c.Response()).Encode(greet); err != nil { + return err + } + c.Response().Flush() closeNotifier := c.Response().CloseNotify() for { select { -- cgit v1.2.3