Thumbnail

rani/matterbridge.git

Clone URL: https://git.buni.party/rani/matterbridge.git

commit db08279aedd57601ab48d3449796c2f3ccb96fd1 Author: NikkyAI <root@nikky.moe> Date: Fri Nov 02 16:35:13 2018 +0000 Respond with message on connect (api) (#550) fix #549 diff --git a/bridge/api/api.go b/bridge/api/api.go index 28c5710..0ccd85b 100644 --- a/bridge/api/api.go +++ b/bridge/api/api.go @@ -1026 +10214 @@ 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 7f8fc3e..eff9309 100644 --- a/bridge/config/config.go +++ b/bridge/config/config.go @@ -226 +227 @@ const (   EVENT_REJOIN_CHANNELS = "rejoin_channels"   EVENT_USER_ACTION = "user_action"   EVENT_MSG_DELETE = "msg_delete" + EVENT_API_CONNECTED = "api_connected"  )    type Message struct {