summaryrefslogtreecommitdiff
path: root/plugins/broadcast/websockets/event.go
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/broadcast/websockets/event.go')
-rw-r--r--plugins/broadcast/websockets/event.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/plugins/broadcast/websockets/event.go b/plugins/broadcast/websockets/event.go
new file mode 100644
index 00000000..3634bb89
--- /dev/null
+++ b/plugins/broadcast/websockets/event.go
@@ -0,0 +1,40 @@
+package websockets
+
+import (
+ "github.com/gorilla/websocket"
+)
+
+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
+)
+
+// ErrorEvent represents singular broadcast error event.
+type ErrorEvent struct {
+ // Conn specific to the error.
+ Conn *websocket.Conn
+
+ // Error contains job specific error.
+ Error error
+}
+
+// TopicEvent caused when topic is joined or left.
+type TopicEvent struct {
+ // Conn associated with topics.
+ Conn *websocket.Conn
+
+ // Topics specific to event.
+ Topics []string
+}