diff options
author | NikkyAI <root@nikky.moe> | 2018-11-02 16:35:13 +0100 |
---|---|---|
committer | Wim <wim@42.be> | 2018-11-02 16:35:13 +0100 |
commit | d058be25ad93bf6a0c206ac33ed7db07d1479573 (patch) | |
tree | 859a01d763e686a8fde55c8c4906d303bc0396e3 | |
parent | 1269be1d0472430d51b821639fb7d35e23f90887 (diff) | |
download | matterbridge-msglm-d058be25ad93bf6a0c206ac33ed7db07d1479573.tar.gz matterbridge-msglm-d058be25ad93bf6a0c206ac33ed7db07d1479573.tar.bz2 matterbridge-msglm-d058be25ad93bf6a0c206ac33ed7db07d1479573.zip |
Respond with message on connect (api) (#550)
fix #549
-rw-r--r-- | bridge/api/api.go | 8 | ||||
-rw-r--r-- | bridge/config/config.go | 1 |
2 files changed, 9 insertions, 0 deletions
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 { diff --git a/bridge/config/config.go b/bridge/config/config.go index 7f8fc3ee..eff93094 100644 --- a/bridge/config/config.go +++ b/bridge/config/config.go @@ -22,6 +22,7 @@ const ( EVENT_REJOIN_CHANNELS = "rejoin_channels" EVENT_USER_ACTION = "user_action" EVENT_MSG_DELETE = "msg_delete" + EVENT_API_CONNECTED = "api_connected" ) type Message struct { |