5
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2024-12-24 17:15:40 +00:00

Respond with message on connect (api) (#550)

fix #549
This commit is contained in:
NikkyAI 2018-11-02 16:35:13 +01:00 committed by Wim
parent 1269be1d04
commit d058be25ad
2 changed files with 9 additions and 0 deletions

View File

@ -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 {

View File

@ -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 {