YAACC - UPNP Client and Server
Loading...
Searching...
No Matches
de.yaacc.fcast.FCastReceiverLinks Class Reference

The sessions that the screens open on demand (design.md, "Connection lifecycle", decision D11): the volume of an idle card, the settings sheet. More...

Collaboration diagram for de.yaacc.fcast.FCastReceiverLinks:
Collaboration graph

Classes

interface  Factory
 Makes the session of a receiver (the one of the app connects over TCP; a test makes one to a fake receiver). More...
 
class  Link
 One use of a session; close it when done. More...
 

Public Member Functions

 FCastReceiverLinks (Factory factory, ScheduledExecutorService timers)
 
 FCastReceiverLinks (Factory factory, ScheduledExecutorService timers, long closeAfterMillis)
 
 FCastReceiverLinks (Factory factory, ScheduledExecutorService timers, long closeAfterMillis, java.util.function.Supplier< ScheduledExecutorService > sessionExecutors)
 
synchronized Link open (FCastEndpoint endpoint)
 Opens a link to the receiver: its session is made if there is none (no connection yet: the first command connects).
 
synchronized boolean isOpen (FCastEndpoint endpoint)
 True if a session of this receiver is open here (for the text of an idle card: no connection means no state).
 
synchronized FCastSession peek (FCastEndpoint endpoint)
 The session of the receiver if one is open here, else null.
 
synchronized void handOverToPlayer (FCastEndpoint endpoint)
 A player takes the receiver: the session of the screens closes at once (never two connections to one receiver).
 
synchronized void closeAll ()
 Closes everything (the app exits).
 

Static Public Attributes

static final int MAX_SESSIONS = 8
 
static final long CLOSE_AFTER_MILLIS = 35_000L
 

Detailed Description

The sessions that the screens open on demand (design.md, "Connection lifecycle", decision D11): the volume of an idle card, the settings sheet.

An idle card has no connection; whoever needs one opens a link, uses its session, and closes the link, and the session is closed {@value CLOSE_AFTER_MILLIS} ms after the last link of the receiver was closed (a short grace so that a second tap or the sheet that opens next uses the same connection). Each session has its own thread, so a receiver that does not answer blocks only itself. A receiver has at most one session here, at most {@value MAX_SESSIONS} receivers are open at once (the global cap of the security rules), and a receiver that a player plays to is left to the player (handOverToPlayer: the player has its own session and there is never a second connection to the same receiver). Thread safe; the sessions run on the executor that was given.

Constructor & Destructor Documentation

◆ FCastReceiverLinks() [1/2]

de.yaacc.fcast.FCastReceiverLinks.FCastReceiverLinks ( Factory factory,
ScheduledExecutorService timers,
long closeAfterMillis )
Parameters
closeAfterMillisthe grace time before the session of a receiver without links is closed (a test makes it short)

◆ FCastReceiverLinks() [2/2]

de.yaacc.fcast.FCastReceiverLinks.FCastReceiverLinks ( Factory factory,
ScheduledExecutorService timers,
long closeAfterMillis,
java.util.function.Supplier< ScheduledExecutorService > sessionExecutors )
Parameters
sessionExecutorsmakes the thread of one session; a test passes its own

Member Function Documentation

◆ open()

synchronized Link de.yaacc.fcast.FCastReceiverLinks.open ( FCastEndpoint endpoint)

Opens a link to the receiver: its session is made if there is none (no connection yet: the first command connects).

Returns
the link, null if the cap of open receivers is reached. The caller asks the player first: a receiver that a player plays to is controlled through the player's own session, never through a link
Here is the call graph for this function:

The documentation for this class was generated from the following file: