|
YAACC - UPNP Client and Server
|
Task 12C: the one switch of the phone's own Snapcast client, without Android. More...

Classes | |
| enum | Outcome |
| What a call came to. More... | |
| class | RestoreResult |
| What a restore came to: the decision, and the outcome of the start when one was made (null when skipped). | |
| interface | Session |
The service of the client; SnapcastClientRuntime and SnapcastClientService in the app. More... | |
| enum | Shown |
| What the switch and the dialog show. More... | |
| class | State |
| The state to show: where the client is, and how its last session ended. | |
| interface | Store |
The persisted settings and the state; SharedPreferences in the app. More... | |
Public Member Functions | |
| SnapcastClientPower (Store store, Session session, Consumer< String > log) | |
| SnapcastClientPower (Store store, Session session, Consumer< String > log, java.util.function.LongSupplier clock) | |
| boolean | isOn () |
| boolean | offered () |
| Outcome | setOn (boolean on) |
| The switch, the checkbox, the dialog: sets the state and starts or stops the session. | |
| synchronized Outcome | applyOption () |
| The rule for the client changed (support, services or the client switch went off or on, issue #330): a session that runs while the client is not allowed any more ends, and the client connects when it is allowed again and was switched on. | |
| synchronized RestoreResult | restore (SnapcastClientRestore.Point point, boolean exitHold) |
The application starts the client again from the state (SnapcastClientRestore). | |
| State | state () |
| What to show now. | |
| boolean | isPoweredOn () |
| What the power button of the card shows (tasks 12.4 part 2 and 12.16): on while a session starts, runs or reconnects, while a restart on another server waits, and for a moment after a start was handed to the service (the session shows its first phase a moment later); off when the client is switched off, and also when it is switched on but has no session (it gave up, or a start was refused: a tap starts it again). | |
| Outcome | chooseServer (String hostText) |
| The user chose a server on the card of the client (task 12.10): it is remembered as the one the next start uses. | |
| void | markEndingSeen () |
| The switch or the dialog showed the last ending: it is not unseen any more. | |
Task 12C: the one switch of the phone's own Snapcast client, without Android.
The state "switched on" is ONE persisted boolean (SnapcastClient#KEY_SWITCHED_ON); this class is the only place that writes it. The switch on the first page, the checkbox of the settings, the listen test dialog and (next run) the power button of the card all go through setOn; the application restores from it at the start (restore).
Outcome (the caller shows its reason) and the reason is kept as the last ending, so that the switch and the dialog show "stopped" with it. No retry loop. Nothing here is logged but class names and fixed words: never the address, never the message of an exception.
| de.yaacc.snapcast.client.SnapcastClientPower.SnapcastClientPower | ( | Store | store, |
| Session | session, | ||
| Consumer< String > | log, | ||
| java.util.function.LongSupplier | clock ) |
| clock | milliseconds, only differences are used (a fake in the tests) |
| synchronized Outcome de.yaacc.snapcast.client.SnapcastClientPower.applyOption | ( | ) |
The rule for the client changed (support, services or the client switch went off or on, issue #330): a session that runs while the client is not allowed any more ends, and the client connects when it is allowed again and was switched on.
What the user chose on the card is the intent and is never written here. Idempotent.
Referenced by de.yaacc.snapcast.SnapcastServices.install().

| Outcome de.yaacc.snapcast.client.SnapcastClientPower.chooseServer | ( | String | hostText | ) |
The user chose a server on the card of the client (task 12.10): it is remembered as the one the next start uses.
While the client is on and connected to another server, the session ends and starts again on it (one restart; the state stays on; the same server restarts nothing); while it is off, nothing starts. The option is checked again and the address is validated like on every start. No automatic failover: this is the only way the server changes.
| hostText | the text of one of the known servers (host or host:port) |

| boolean de.yaacc.snapcast.client.SnapcastClientPower.isOn | ( | ) |
| boolean de.yaacc.snapcast.client.SnapcastClientPower.offered | ( | ) |
SnapcastClientServerChoice) 
| synchronized RestoreResult de.yaacc.snapcast.client.SnapcastClientPower.restore | ( | SnapcastClientRestore.Point | point, |
| boolean | exitHold ) |
The application starts the client again from the state (SnapcastClientRestore).
Never clears the state.
| exitHold | the process was created right after an explicit exit and waits for the user |
Referenced by de.yaacc.snapcast.client.SnapcastClientPowers.restore().

| Outcome de.yaacc.snapcast.client.SnapcastClientPower.setOn | ( | boolean | on | ) |
The switch, the checkbox, the dialog: sets the state and starts or stops the session.
Call from the main thread.
Outcome#STOPPED for off; Outcome#STARTED or Outcome#ALREADY_ACTIVE for on, or the refusal