lobby/nats_driver/types.go

21 lines
556 B
Go
Raw Normal View History

package nats_driver
2021-09-02 00:13:12 +00:00
import (
"encoding/json"
"github.com/by-cx/lobby/server"
2021-09-02 00:13:12 +00:00
)
// discoveryEnvelope adds a message to the standard discovery format. The message
// can be "hi" or "goodbye" where "hi" is used when the node is sending keep alive
// packets and "goodbye" means the node is leaving.
type discoveryEnvelope struct {
Discovery server.Discovery `json:"discovery"`
Message string `json:"message"` // can be hi or goodbye
}
func (e *discoveryEnvelope) Bytes() ([]byte, error) {
body, err := json.Marshal(e)
return body, err
}