Documentation ¶
Index ¶
- type Subscriber
- type WsHandler
- func (ws *WsHandler) EnableDebugMode()
- func (ws *WsHandler) HasSubscriber() bool
- func (ws *WsHandler) Publish(msg []byte)
- func (ws *WsHandler) PublishJSON(v interface{})
- func (ws *WsHandler) PublishTo(s *Subscriber, msg []byte)
- func (ws *WsHandler) PublishToJSON(s *Subscriber, v interface{})
- func (ws *WsHandler) SubscribeHandler(w http.ResponseWriter, r *http.Request)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Subscriber ¶
type Subscriber struct {
// contains filtered or unexported fields
}
Subscriber represents a subscriber. Messages are sent on the msgs channel and if the client cannot keep up with the messages, closeSlow is called.
type WsHandler ¶ added in v0.0.2
type WsHandler struct { OnNewSubscriber func(s *Subscriber) AcceptOptions *websocket.AcceptOptions // contains filtered or unexported fields }
WsHandler enables broadcasting to a set of subscribers.
func NewWsHandler ¶
func NewWsHandler() *WsHandler
NewWsHandler constructs a WsHandler with the defaults.
func (*WsHandler) EnableDebugMode ¶ added in v0.0.2
func (ws *WsHandler) EnableDebugMode()
EnableDebugMode set the AcceptOptions.InsecureSkipVerify = true
func (*WsHandler) HasSubscriber ¶ added in v0.0.2
HasSubscriber returns true if there a webclients subscribed, false otherwise
func (*WsHandler) Publish ¶ added in v0.0.2
Publish publishes the msg to all subscribers. It never blocks and so messages to slow subscribers are dropped.
func (*WsHandler) PublishJSON ¶ added in v0.0.2
func (ws *WsHandler) PublishJSON(v interface{})
PublishJSON published as json, in calls json.Marshal internally
func (*WsHandler) PublishTo ¶ added in v0.0.2
func (ws *WsHandler) PublishTo(s *Subscriber, msg []byte)
PublishTo publishes the msg to a single subscribers.
func (*WsHandler) PublishToJSON ¶ added in v0.0.2
func (ws *WsHandler) PublishToJSON(s *Subscriber, v interface{})
PublishJSON published to a single subscriber as json, in calls json.Marshal internally
func (*WsHandler) SubscribeHandler ¶ added in v0.0.2
func (ws *WsHandler) SubscribeHandler(w http.ResponseWriter, r *http.Request)
SubscribeHandler accepts the WebSocket connection and then subscribes it to all future messages.