Documentation ¶
Index ¶
Constants ¶
View Source
const ( // EventConnect fired when new client is connected, the context is *websocket.Conn. EventConnect = iota + 2500 // EventDisconnect fired when websocket is disconnected, context is empty. EventDisconnect // EventJoin caused when topics are being consumed, context if *TopicEvent. EventJoin // EventLeave caused when topic consumption are stopped, context if *TopicEvent. EventLeave // EventError when any broadcast error occurred, the context is *ErrorEvent. EventError )
View Source
const ID = "ws"
ID defines service id.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // Path defines on this URL the middleware must be activated. Same path must // be handled by underlying application kernel to authorize the consumption. Path string // NoOrigin disables origin check, only for debug. NoOrigin bool }
Config defines the websocket service configuration.
type ConnContext ¶
type ConnContext struct { // Conn to the client. Conn *websocket.Conn // Topics contain list of currently subscribed topics. Topics []string // contains filtered or unexported fields }
ConnContext carries information about websocket connection and it's topics.
func (*ConnContext) SendMessage ¶
func (ctx *ConnContext) SendMessage(topic string, payload interface{}) (err error)
SendMessage message directly to the client.
type ErrorEvent ¶
type ErrorEvent struct { // Conn specific to the error. Conn *websocket.Conn // Error contains job specific error. Error error }
ErrorEvent represents singular broadcast error event.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service to manage websocket clients.
func (*Service) AddListener ¶
AddListener attaches server event controller.
type TopicEvent ¶
type TopicEvent struct { // Conn associated with topics. Conn *websocket.Conn // Topics specific to event. Topics []string }
TopicEvent caused when topic is joined or left.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.