|
YAACC - UPNP Client and Server
|
Everything that belongs to one snapserver: the control connection (SnapcastRpc), the model that follows the server's notifications (SnapcastModelUpdater) and the control calls (SnapcastOperations).
More...


Public Member Functions | |
| SnapcastSession (ServerKey key, SnapcastTransport transport, SnapcastRpc.Config config, MonotonicClock clock, RetryScheduler scheduler) | |
| ServerKey | getKey () |
| SnapcastOperations | getOperations () |
| The calls that change the server. | |
| SnapcastServerStatus | getStatus () |
| The last status that was read; null before the first one. | |
| boolean | isOnline () |
| True while the control connection is up. | |
| boolean | hasGivenUp () |
True when the reconnects stopped after too many failures; retry() starts them again. | |
| SnapcastException.Kind | getLastErrorKind () |
| The kind of the last connection or read failure; null when the last read or connection succeeded. | |
| int | getLastErrorCode () |
| The JSON-RPC code of the last failure (401 or 403 when the server wants authorization), else 0. | |
| InetAddress | getPeerAddress () |
| The address of the control connection, or null without one. | |
| long | getConnectionGeneration () |
| A number that changes with every new control connection of this link and never goes back; 0 for a fake. | |
| void | addListener (Listener listener) |
| void | removeListener (Listener listener) |
| void | start () |
| Opens the connection (does nothing when started already). | |
| void | retry () |
| Connects now if the link waits for a retry or gave up. | |
| void | close () |
| Releases the connection and every thread. | |
Public Member Functions inherited from de.yaacc.snapcast.SnapcastServerLink | |
Everything that belongs to one snapserver: the control connection (SnapcastRpc), the model that follows the server's notifications (SnapcastModelUpdater) and the control calls (SnapcastOperations).
It exposes the current immutable SnapcastServerStatus, tells its listeners when the status or the connection changed, and releases every thread on close(). Pure Java (the transport is injected).
How it follows the usage notes of the control library.
onConnected), on the worker. A re-read that fails (a timeout, a connection problem; not an error the server answered) is requested again through the updater, which keeps its limit of one per second and ten per minute; a held-back request is delivered by a one-second tick that runs only while the connection is up. After {@value MAX_READ_RETRIES} failures in a row it gives up until the next doubt or connection. retry() (the receivers page became visible) is the only caller of SnapcastRpc.retry(); it resets the failure count of the reconnects, so it is never called by a loop here. getOperations() goes through callOrdered, so the model follows it in line order; the listeners are told after it. Threads: the reader and the writer of the RPC, one listener thread, one worker and (without an injected scheduler) one timer thread. Names and ids in the status are display text of the server, never an identity.
| de.yaacc.snapcast.SnapcastSession.SnapcastSession | ( | ServerKey | key, |
| SnapcastTransport | transport, | ||
| SnapcastRpc.Config | config, | ||
| MonotonicClock | clock, | ||
| RetryScheduler | scheduler ) |
| transport | opens the control connection (for the app: a SocketTransport to an address that was resolved with a time limit) |
| config | the limits of the connection |
| scheduler | runs the reconnect timers and the tick; null: an own timer thread |

| void de.yaacc.snapcast.SnapcastSession.addListener | ( | Listener | listener | ) |
Implements de.yaacc.snapcast.SnapcastServerLink.
| void de.yaacc.snapcast.SnapcastSession.close | ( | ) |
Releases the connection and every thread.
The listeners are told once, before they are dropped, that the link is offline (isOnline() is false in the call): whoever depends on the link (a feed that writes to the server of this link) learns that it is gone and stops (security review W1: removing a server must end a running feed). The call is made on the calling thread and holds no lock of this class; a listener that fails is skipped.
Implements de.yaacc.snapcast.SnapcastServerLink.
| long de.yaacc.snapcast.SnapcastSession.getConnectionGeneration | ( | ) |
A number that changes with every new control connection of this link and never goes back; 0 for a fake.
Implements de.yaacc.snapcast.SnapcastServerLink.
| ServerKey de.yaacc.snapcast.SnapcastSession.getKey | ( | ) |
Implements de.yaacc.snapcast.SnapcastServerLink.
| SnapcastOperations de.yaacc.snapcast.SnapcastSession.getOperations | ( | ) |
The calls that change the server.
They block: make them on a worker, never on the main thread.
Implements de.yaacc.snapcast.SnapcastServerLink.
| InetAddress de.yaacc.snapcast.SnapcastSession.getPeerAddress | ( | ) |
The address of the control connection, or null without one.
The feed of a stream connects to this address and to no other. It is an address of the local network: never log it.
Implements de.yaacc.snapcast.SnapcastServerLink.
| SnapcastServerStatus de.yaacc.snapcast.SnapcastSession.getStatus | ( | ) |
The last status that was read; null before the first one.
It is kept while the server is offline.
Implements de.yaacc.snapcast.SnapcastServerLink.
| boolean de.yaacc.snapcast.SnapcastSession.isOnline | ( | ) |
True while the control connection is up.
Implements de.yaacc.snapcast.SnapcastServerLink.
| void de.yaacc.snapcast.SnapcastSession.removeListener | ( | Listener | listener | ) |
Implements de.yaacc.snapcast.SnapcastServerLink.
| void de.yaacc.snapcast.SnapcastSession.retry | ( | ) |
Connects now if the link waits for a retry or gave up.
Implements de.yaacc.snapcast.SnapcastServerLink.
| void de.yaacc.snapcast.SnapcastSession.start | ( | ) |
Opens the connection (does nothing when started already).
Implements de.yaacc.snapcast.SnapcastServerLink.