|
YAACC - UPNP Client and Server
|
The snapservers YAACC knows: the ones found by mDNS and the ones the user typed in, merged by control endpoint (ServerKey).
More...

Classes | |
| class | Entry |
| One server of the list. | |
| interface | Listener |
| Told when the list of servers changed; called on the thread that made the change, without a lock held. More... | |
Public Member Functions | |
| SnapcastDirectory (MonotonicClock clock, long graceMillis) | |
| void | addListener (Listener listener) |
| void | removeListener (Listener listener) |
| boolean | serviceFound (String serviceName, InetAddress address, int port) |
| A service was found and resolved; its name is both its identity and its display text. | |
| boolean | serviceFound (String serviceId, String serviceName, InetAddress address, int port) |
A service was found and resolved, with an identity of its own: the same name under two service types (a server of Snapcast 0.32 announces its control port twice, see SnapcastServiceTypes) is two services, so the loss of one does not drop the server while the other is still announced. | |
| void | serviceLost (String serviceName) |
A service is gone (a "lost" event names only the service; the id is the one given to serviceFound). | |
| void | discoveryRestarted () |
| Discovery starts again (the receivers page came back): nothing is known to be announced until it is seen again, so every discovered entry that is not manual starts its grace period now. | |
| void | discoveryStopped () |
| Discovery is switched off (the setting, or no page is visible and it is not wanted): nothing is announced any more as far as this list can know. | |
| int | setManualServers (Collection< ServerEndpoint > endpoints) |
| Replaces the manual servers. | |
| int | setRememberedServers (Collection< ServerEndpoint > endpoints) |
| Replaces the remembered servers: the servers that hold a selected group, kept from an earlier run so that the selection can be reconnected. | |
| boolean | expire () |
| Removes the servers whose grace period is over. | |
| List< Entry > | servers () |
| The servers, sorted by key (a stable order). | |
| List< Entry > | snapshot () |
Like servers(), but quiet: servers past their grace period are left out instead of being removed, and no listener is called. | |
| Entry | find (ServerKey key) |
Static Public Attributes | |
| static final int | MAX_SERVERS = ManualServers.MAX_SERVERS |
| The most servers listed (discovered and manual together). | |
| static final int | MAX_SERVICE_NAMES = 32 |
| The most service names remembered, so that a flood of names does not grow the directory. | |
| static final long | DEFAULT_GRACE_MILLIS = 30_000L |
| How long a lost server stays listed. | |
| static final int | MIN_DISCOVERED_PORT = 1024 |
| The lowest port taken from an announcement. | |
The snapservers YAACC knows: the ones found by mDNS and the ones the user typed in, merged by control endpoint (ServerKey).
Pure and thread safe; the clock is injected.
setRememberedServers): it is listed from the start, without being announced, and is not aged out by time (nothing is scanned outside the page lifetime, so nothing could confirm it). When discovery starts again it gets the same grace as any discovered entry: seen in that time it stays, otherwise it goes. MAX_SERVERS entries. A lost entry makes room first; manual entries may also take the place of a discovered one, never the other way round. AddressFilter. Service names come from the network: they are kept to match "lost" events and as display text (cleaned and cut), never as an identity. | void de.yaacc.snapcast.discovery.SnapcastDirectory.discoveryStopped | ( | ) |
Discovery is switched off (the setting, or no page is visible and it is not wanted): nothing is announced any more as far as this list can know.
A server that only discovery knew goes at once (its grace period is for a hiccup, not for a switch); a typed-in or remembered server stays, and stays for good: it is no longer waiting for a sighting that can not come, so the grace period it got when the scan began is cancelled.
| boolean de.yaacc.snapcast.discovery.SnapcastDirectory.expire | ( | ) |
Removes the servers whose grace period is over.
| Entry de.yaacc.snapcast.discovery.SnapcastDirectory.find | ( | ServerKey | key | ) |
| List< Entry > de.yaacc.snapcast.discovery.SnapcastDirectory.servers | ( | ) |
The servers, sorted by key (a stable order).
Servers past their grace period are not in it.
Referenced by de.yaacc.snapcast.SnapcastSelectedServers.selectionChanged().

| boolean de.yaacc.snapcast.discovery.SnapcastDirectory.serviceFound | ( | String | serviceId, |
| String | serviceName, | ||
| InetAddress | address, | ||
| int | port ) |
A service was found and resolved, with an identity of its own: the same name under two service types (a server of Snapcast 0.32 announces its control port twice, see SnapcastServiceTypes) is two services, so the loss of one does not drop the server while the other is still announced.
The name is display text only.
| serviceId | what serviceLost(String) will be given; see SnapcastServiceTypes#serviceId |
| serviceName | the name the network gave the service |
serviceFound(String, InetAddress, int) 
| boolean de.yaacc.snapcast.discovery.SnapcastDirectory.serviceFound | ( | String | serviceName, |
| InetAddress | address, | ||
| int | port ) |
A service was found and resolved; its name is both its identity and its display text.
Referenced by de.yaacc.snapcast.discovery.SnapcastDirectory.serviceFound().


| int de.yaacc.snapcast.discovery.SnapcastDirectory.setManualServers | ( | Collection< ServerEndpoint > | endpoints | ) |
Replaces the manual servers.
An entry that is no longer on the list but is still announced stays as a discovered one; otherwise it goes at once.
MAX_SERVERS at most) Referenced by de.yaacc.snapcast.SnapcastHub.pageStarted(), and de.yaacc.snapcast.SnapcastHub.wake().


| int de.yaacc.snapcast.discovery.SnapcastDirectory.setRememberedServers | ( | Collection< ServerEndpoint > | endpoints | ) |
Replaces the remembered servers: the servers that hold a selected group, kept from an earlier run so that the selection can be reconnected.
Only an endpoint with an address that passes AddressFilter is taken (a remembered server was discovered once, so it was filtered then; it is filtered again, a stored value is not trusted). A remembered server is listed at once and does not age out by time; when the list is full it takes only the place of a lost entry (a server that is announced or typed in is never pushed out). One that is no longer remembered goes unless it is announced or typed in.
Referenced by de.yaacc.snapcast.SnapcastSelectedServers.forget(), de.yaacc.snapcast.SnapcastSelectedServers.restore(), and de.yaacc.snapcast.SnapcastSelectedServers.selectionChanged().


| List< Entry > de.yaacc.snapcast.discovery.SnapcastDirectory.snapshot | ( | ) |
Like servers(), but quiet: servers past their grace period are left out instead of being removed, and no listener is called.
For code that holds a lock of its own and must not run foreign code under it; whoever calls servers(), expire() or any change later sweeps the left-out entries and tells the listeners.
|
static |
The lowest port taken from an announcement.
Any host of the network (or an app on the phone) can announce a service, and a port below 1024 is never a Snapcast control port in practice (the default is 1705): the phone would be made to open connections to system services (security review S18). A server the user types in may use any port.
Referenced by de.yaacc.snapcast.discovery.SnapcastDirectory.serviceFound().