dial

package
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 28, 2024 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package dial implements a basic DIAL (DIscovery And Launch) client. See http://www.dial-multiscreen.org/

Index

Constants

View Source
const (
	MSearchMinTimeout = time.Duration(mSearchMx)*time.Second + 1*time.Second
	MSearchMaxTimeout = 2 * time.Minute
)

Variables

This section is empty.

Functions

func Discover

func Discover(done chan struct{}, localAddr string, timeout time.Duration) (chan *Device, error)

Discover discovers (unique) DIAL server devices on the network.

Types

type AppInfo

type AppInfo struct {
	Name string `xml:"name"`

	// State valid values are:
	// - running: the application is installed and either starting or running;
	// - stopped: the application is installed and not running;
	// - installable=<URL>: the application is not installed but is
	//   available for installation by sending an HTTP GET request to the
	//   provided URL;
	// - hidden: the application is running but is not visible to the user;
	//
	// any other value is invalid and should be ignored.
	State string `xml:"state"`

	Options struct {
		// AllowStop true indicates that the application can be stopped
		// (if running) sending an HTTP DELETE request to Link.Href.
		AllowStop bool `xml:"allowStop,attr"`
	} `xml:"options"`

	// Link is included when the application is running and can be stopped
	// using a DELETE request.
	Link struct {
		// Rel is always "run".
		Rel string `xml:"rel,attr"`

		// Href contains instance URL of the running application.
		Href string `xml:"href,attr"`
	} `xml:"link"`

	Additional struct {
		// Additional.Data contains zero or more (dynamic) XML elements
		// specific to the application.
		Data string `xml:",innerxml"`
	} `xml:"additionalData"`
}

AppInfo contains information about an application on a specific Device.

type Device

type Device struct {
	UniqueServiceName string // UniqueServiceName from the ssdpService.
	Location          string // Location from the ssdpService.
	ApplicationUrl    string // base DIAL REST service url.
	FriendlyName      string // UPnP friendlyName field of the device description.
	Wakeup            Wakeup // WAKEUP header values from the ssdpService (if available).
	// contains filtered or unexported fields
}

Device is a DIAL server device discovered on the network.

func (*Device) GetAppInfo

func (d *Device) GetAppInfo(appName, origin string) (*AppInfo, error)

GetAppInfo returns information about an application on the Device. appName should be an application name registered in the DIAL Registry. origin (if present) will be passed as Origin HTTP header.

func (*Device) Hostname added in v0.2.0

func (d *Device) Hostname() string

Hostname returns the Device's hostname extracted from ApplicationUrl.

func (*Device) Launch

func (d *Device) Launch(appName, origin, payload string) (string, error)

Launch launches (starts) an application on the Device and returns its instance url (if available). appName should be an application name registered in the DIAL Registry. origin (if present) will be passed as Origin HTTP header. payload (if present) will be passed as HTTP message body with Content-Type: text/plain; charset=utf-8 header.

func (*Device) Ping

func (d *Device) Ping() bool

Ping returns true if the Device is up i.e. if it responds to requests.

func (*Device) SetLocalAddr added in v1.4.0

func (d *Device) SetLocalAddr(localAddr string) error

SetLocalAddr sets the local address the Device instance must use for network operations.

func (*Device) TryWakeup

func (d *Device) TryWakeup() error

TryWakeup tries to Wake-On-Lan the Device sending magic packets to its MAC address and waiting for it to become available. It eventually updates Location and ApplicationUrl (re-Discover) because the Device may have changed ip address and/or service ports. Returns nil if it successfully wakes up the Device.

type Wakeup

type Wakeup struct {
	Mac     string        // MAC address of the device's wired or wireless network interface.
	Timeout time.Duration // estimated upper bound of the duration needed to wake the device and start its DIAL server.
}

Wakeup contains values of WAKEUP header from the ssdpService that can be used to WoL or WoWLAN the device.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL