blob: 17e6780f046fb317d79a73c7d55a6bb315bb074e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
package pubsub
import (
json "github.com/json-iterator/go"
)
type Msg struct {
// Topic message been pushed into.
Topics_ []string `json:"topic"`
// Command (join, leave, headers)
Command_ string `json:"command"`
// Broker (redis, memory)
Broker_ string `json:"broker"`
// Payload to be broadcasted
Payload_ []byte `json:"payload"`
}
// MarshalBinary needed to marshal message for the redis
func (m *Msg) MarshalBinary() ([]byte, error) {
return json.Marshal(m)
}
// Payload in raw bytes
func (m *Msg) Payload() []byte {
return m.Payload_
}
// Command for the connection
func (m *Msg) Command() string {
return m.Command_
}
// Topics to subscribe
func (m *Msg) Topics() []string {
return m.Topics_
}
func (m *Msg) Broker() string {
return m.Broker_
}
|