2024-01-12 12:11:41 +01:00
|
|
|
package cast
|
|
|
|
|
|
|
|
import "net"
|
|
|
|
|
|
|
|
type DeviceType string
|
|
|
|
|
|
|
|
type Device interface {
|
|
|
|
DeviceType() DeviceType
|
|
|
|
DeviceHost() net.IP
|
|
|
|
DevicePort() int
|
|
|
|
DeviceName() string
|
|
|
|
DeviceID() string
|
|
|
|
}
|
2024-01-12 14:02:53 +01:00
|
|
|
|
|
|
|
type legacyDevice struct {
|
|
|
|
Device `json:"-"`
|
|
|
|
UUID string `goja:"uuid" json:"uuid"`
|
|
|
|
Host string `goja:"host" json:"host"`
|
|
|
|
Port int `goja:"port" json:"port"`
|
|
|
|
Name string `goja:"name" json:"name"`
|
|
|
|
Type string `goja:"type" json:"type"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func toLegacyDevice(device Device) *legacyDevice {
|
|
|
|
return &legacyDevice{
|
|
|
|
Device: device,
|
|
|
|
UUID: device.DeviceID(),
|
|
|
|
Host: device.DeviceHost().String(),
|
|
|
|
Port: device.DevicePort(),
|
|
|
|
Name: device.DeviceName(),
|
|
|
|
Type: string(device.DeviceType()),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func toLegacyDevices(devices ...Device) []*legacyDevice {
|
|
|
|
legacyDevices := make([]*legacyDevice, len(devices))
|
|
|
|
for i, d := range devices {
|
|
|
|
legacyDevices[i] = toLegacyDevice(d)
|
|
|
|
}
|
|
|
|
return legacyDevices
|
|
|
|
}
|