Live: http publish, refactor live interfaces (#32317)

This commit is contained in:
Alexander Emelin
2021-03-30 13:23:29 +03:00
committed by GitHub
parent 84ea3a73c0
commit da05b7a07b
10 changed files with 191 additions and 95 deletions
+8 -12
View File
@@ -1,9 +1,9 @@
package features
import (
"context"
"encoding/json"
"github.com/centrifugal/centrifuge"
"github.com/grafana/grafana/pkg/models"
)
@@ -26,20 +26,16 @@ func (h *DashboardHandler) GetHandlerForPath(path string) (models.ChannelHandler
}
// OnSubscribe for now allows anyone to subscribe to any dashboard
func (h *DashboardHandler) OnSubscribe(c *centrifuge.Client, e centrifuge.SubscribeEvent) (centrifuge.SubscribeReply, error) {
return centrifuge.SubscribeReply{
Options: centrifuge.SubscribeOptions{
Presence: true,
JoinLeave: true,
},
}, nil
func (h *DashboardHandler) OnSubscribe(ctx context.Context, _ *models.SignedInUser, e models.SubscribeEvent) (models.SubscribeReply, bool, error) {
return models.SubscribeReply{
Presence: true,
JoinLeave: true,
}, true, nil
}
// OnPublish is called when someone begins to edit a dashoard
func (h *DashboardHandler) OnPublish(c *centrifuge.Client, e centrifuge.PublishEvent) (centrifuge.PublishReply, error) {
return centrifuge.PublishReply{
Options: centrifuge.PublishOptions{},
}, nil
func (h *DashboardHandler) OnPublish(ctx context.Context, _ *models.SignedInUser, e models.PublishEvent) (models.PublishReply, bool, error) {
return models.PublishReply{}, true, nil
}
// DashboardSaved should broadcast to the appropriate stream