You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

27 lines
537 B

package models
import "strconv"
type Event struct {
Name string `json:"name"`
Payload map[string]string `json:"payload,omitempty"`
}
func (e *Event) AddPayload(key, value string) {
if e.Payload == nil {
e.Payload = make(map[string]string, 8)
}
e.Payload[key] = value
}
func (e *Event) HasPayload(key string) bool {
return e.Payload != nil && e.Payload[key] != ""
}
func BridgeConnectedEvent(bridge Bridge) Event {
e := Event{Name: "BridgeConnected"}
e.AddPayload("id", strconv.Itoa(bridge.ID))
return e
}