Live: update centrifuge and the ChannelHandler api (#28843)

This commit is contained in:
Ryan McKinley
2020-11-05 10:37:04 -08:00
committed by GitHub
parent d736fcdd1d
commit b91e9faccf
10 changed files with 109 additions and 206 deletions
+4 -8
View File
@@ -7,15 +7,11 @@ type ChannelPublisher func(channel string, data []byte) error
// ChannelHandler defines the core channel behavior
type ChannelHandler interface {
// This is called fast and often -- it must be synchrnozed
GetChannelOptions(id string) centrifuge.ChannelOptions
// OnSubscribe is called when a client wants to subscribe to a channel
OnSubscribe(c *centrifuge.Client, e centrifuge.SubscribeEvent) (centrifuge.SubscribeReply, error)
// Called when a client wants to subscribe to a channel
OnSubscribe(c *centrifuge.Client, e centrifuge.SubscribeEvent) error
// AllowBroadcast is called when a client writes a message to the channel websocket.
// Returning an error will cancel the broadcast.
AllowBroadcast(c *centrifuge.Client, e centrifuge.PublishEvent) error
// OnPublish is called when a client writes a message to the channel websocket.
OnPublish(c *centrifuge.Client, e centrifuge.PublishEvent) (centrifuge.PublishReply, error)
}
// ChannelHandlerFactory should be implemented by all core features.