2021-09-02 17:22:39 +00:00
|
|
|
package nats_driver
|
2021-09-02 00:13:12 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
|
2021-09-06 22:46:48 +00:00
|
|
|
"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
|
|
|
|
}
|