func (p *Mpris) SendRequest(device *network.Device, playerList bool, volume bool, nowPlaying bool) error { return device.Send(MprisType, &MprisBody{ RequestPlayerList: playerList, RequestVolume: volume, RequestNowPlaying: nowPlaying, }) }
func (e *Engine) sendIdentity(device *network.Device) error { return device.Send(protocol.IdentityType, &protocol.Identity{ DeviceId: e.config.DeviceId, DeviceName: e.config.DeviceName, ProtocolVersion: protocol.Version, DeviceType: e.config.DeviceType, TcpPort: e.config.TcpPort, }) }
func (e *Engine) PairDevice(device *network.Device) error { if device.Paired { return nil } if !device.PairRequestSent { pair := &protocol.Pair{ Pair: true, } pub, err := e.config.PrivateKey.PublicKey().Marshal() if err != nil { return err } pair.PublicKey = string(pub) err = device.Send(protocol.PairType, pair) if err != nil { return err } log.Println("Sent pairing request to", device.Name) device.PairRequestSent = true } if device.PairRequestReceived && device.PairRequestSent { device.Paired = true log.Println("Device", device.Name, "paired") if e.getKnownDevice(device) == -1 { // Add it to the list of known devices e.config.KnownDevices = append(e.config.KnownDevices, NewKnownDeviceFromDevice(device)) } select { case e.Paired <- device: default: } } return nil }
func (e *Engine) UnpairDevice(device *network.Device) error { if device.Paired { err := device.Send(protocol.PairType, &protocol.Pair{ Pair: false, }) if err != nil { return err } device.Paired = false } select { case e.Unpaired <- device: default: } return nil }
func (p *Ping) SendPing(device *network.Device) error { return device.Send(PingType, nil) }
func (p *Mpris) SendSeek(device *network.Device, seek float64) error { return device.Send(MprisType, &MprisBody{ Seek: seek, }) }
func (p *Mpris) SendSetPosition(device *network.Device, position float64) error { return device.Send(MprisType, &MprisBody{ SetPosition: position, }) }
func (p *Mpris) SendSetVolume(device *network.Device, volume int) error { return device.Send(MprisType, &MprisBody{ SetVolume: volume, }) }
func (p *Mpris) SendAction(device *network.Device, action string) error { return device.Send(MprisType, &MprisBody{Action: action}) }
func (p *Mpris) SendPlayerList(device *network.Device, playerList []string) error { return device.Send(MprisType, &MprisBody{PlayerList: playerList}) }
func (p *Battery) SendRequest(device *network.Device) error { return device.Send(BatteryType, &BatteryBody{Request: true}) }
func (p *Notification) SendRequest(device *network.Device) error { return device.Send(NotificationType, &NotificationBody{Request: true}) }
func (p *Sftp) SendStartBrowsing(device *network.Device) error { return device.Send(SftpType, &SftpBody{StartBrowsing: true}) }