Files
spaceDevices/mqtt/structs.go
2018-01-05 21:09:50 +01:00

54 lines
1.0 KiB
Go

package mqtt
import (
"strings"
)
type WifiSession struct {
Ip string
Mac string
Vlan string
AP int
}
type Devices struct {
Name string `json:"name"`
Location string `json:"location"`
}
type DevicesSorter []Devices
func (s DevicesSorter) Len() int {
return len(s)
}
func (s DevicesSorter) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
}
func (s DevicesSorter) Less(i, j int) bool {
return strings.Compare(s[i].Name, s[j].Name) < 0
}
type Person struct {
Name string `json:"name"`
Devices []Devices `json:"devices"`
}
type PersonSorter []Person
func (s PersonSorter) Len() int {
return len(s)
}
func (s PersonSorter) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
}
func (s PersonSorter) Less(i, j int) bool {
return strings.Compare(s[i].Name, s[j].Name) < 0
}
type PeopleAndDevices struct {
People []Person `json:"people"`
PeopleCount uint16 `json:"peopleCount"`
DeviceCount uint16 `json:"deviceCount"`
UnknownDevicesCount uint16 `json:"unknownDevicesCount"`
}