Yamaha MusicCast™ v0.1.3 MusicCast.Network

A module for supervising a network of MusicCast™ devices.

The network is the heart of this MusicCast application. It is responsible for discovering devices on the local network (see MusicCast.UPnP.SSDPClient), keeping their state synchronized whenever a device’s state is changing and broadcasting network topology changes and device change events.

Also, the network act as a global registry for running MusicCast.Network.Entity processes. You can find a device on the registry with whereis/1. To get a list of registered devices, see which_devices/1.

You also have the possibility to subscribe to network topoligy changes (for example, when a new device is discovered or when a device goes offline). Additionally, you can subscribe to a device’s changefeed directly. See subscribe/1 and unsubscribe/1 for more details.

Summary

Functions

Adds a new device entity to the network

Starts a network supervisor as part of a supervision tree

Subscribes the current process to notifications from the given entity

Unsubscribes the current process from notification from the given entity

Returns the PID for the registered device id

Returns a list of all registered devices

Functions

Adds a new device entity to the network.

start_link(options \\ [])

Starts a network supervisor as part of a supervision tree.

stop(pid)

See Supervisor.stop/1.

subscribe(entity \\ :network)
subscribe(MusicCast.Network.Entity.device_id | :network) ::
  {:ok, pid} |
  {:error, {:not_found, MusicCast.Network.Entity.device_id}}

Subscribes the current process to notifications from the given entity.

unsubscribe(entity \\ :network)
unsubscribe(MusiCast.Network.device_id | :network) :: :ok

Unsubscribes the current process from notification from the given entity.

Returns the PID for the registered device id.

which_devices(keys \\ :lazy)
which_devices(MusicCast.Network.Entity.lookup_keys | :lazy) :: [tuple]

Returns a list of all registered devices.