diff options
Diffstat (limited to 'pkg/pubsub/message.go')
-rw-r--r-- | pkg/pubsub/message.go | 38 |
1 files changed, 8 insertions, 30 deletions
diff --git a/pkg/pubsub/message.go b/pkg/pubsub/message.go index ab74eb98..2536aece 100644 --- a/pkg/pubsub/message.go +++ b/pkg/pubsub/message.go @@ -6,59 +6,37 @@ import ( type Msg struct { // Topic message been pushed into. - T []string `json:"topic"` + Topics_ []string `json:"topic"` // Command (join, leave, headers) - C string `json:"command"` + Command_ string `json:"command"` // Broker (redis, memory) - B string `json:"broker"` + Broker_ string `json:"broker"` // Payload to be broadcasted - P []byte `json:"payload"` + Payload_ []byte `json:"payload"` } -//func (m Msg) UnmarshalBinary(data []byte) error { -// //Use default gob decoder -// reader := bytes.NewReader(data) -// dec := gob.NewDecoder(reader) -// if err := dec.Decode(&m); err != nil { -// return err -// } -// -// return nil -//} - func (m *Msg) MarshalBinary() ([]byte, error) { - //buf := new(bytes.Buffer) - // - //for i := 0; i < len(m.T); i++ { - // buf.WriteString(m.T[i]) - //} - // - //buf.WriteString(m.C) - //buf.WriteString(m.B) - //buf.Write(m.P) - return json.Marshal(m) - } // Payload in raw bytes func (m *Msg) Payload() []byte { - return m.P + return m.Payload_ } // Command for the connection func (m *Msg) Command() string { - return m.C + return m.Command_ } // Topics to subscribe func (m *Msg) Topics() []string { - return m.T + return m.Topics_ } func (m *Msg) Broker() string { - return m.B + return m.Broker_ } |