YAACC - UPNP Client and Server
Loading...
Searching...
No Matches
de.yaacc.share.ShareKeyTracker< P > Class Template Reference

Remembers which share keys each player used, so that the shares can be released when the player ends. More...

Collaboration diagram for de.yaacc.share.ShareKeyTracker< P >:
Collaboration graph

Public Member Functions

void onPlayerAdded (P player, Collection< String > keys)
 A player became active.
 
void refresh (P player, Collection< String > keys)
 Adds keys the player is known to use now (union with what was remembered).
 
Set< String > onPlayerRemoved (P player)
 The player ended: forgets it.
 
Set< String > keysOf (P player)
 
int trackedPlayers ()
 

Static Public Member Functions

static String keyOfProxyPath (String path, String proxySegment)
 The share key in the path of a proxy URL (/proxy/<key> or /proxy/<deviceId>/<key>): the last segment, if the path starts with the proxy segment and the segment is a well-formed key.
 

Detailed Description

Remembers which share keys each player used, so that the shares can be released when the player ends.

The keys must NOT be read from the player's item list at that moment: a player clears its list when it is destroyed, and the "removed" notification is delivered later (on the main thread), so the list is already empty by then. The glue therefore feeds this tracker early and often (onPlayerAdded, refresh); keys are only ever added, never forgotten, until the player is removed.

Players are tracked by identity (a replaced player can have the same id as its successor). Plain Java and thread safe: it is fed from the thread that removes a player and read on the main thread.

Parameters
<P>the player type

Member Function Documentation

◆ keyOfProxyPath()

static String de.yaacc.share.ShareKeyTracker< P >.keyOfProxyPath ( String path,
String proxySegment )
static

The share key in the path of a proxy URL (/proxy/<key> or /proxy/<deviceId>/<key>): the last segment, if the path starts with the proxy segment and the segment is a well-formed key.

Parameters
paththe decoded URL path, may be null
proxySegmentthe first path segment of the proxy routes, without slashes
Returns
the key, or null if the path is not a proxy path

Referenced by de.yaacc.upnp.UpnpClient.createPlayableItem(), and de.yaacc.upnp.UpnpClient.discardShareOf().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ keysOf()

Set< String > de.yaacc.share.ShareKeyTracker< P >.keysOf ( P player)
Returns
a copy of the keys remembered for the player (empty if unknown)

◆ onPlayerAdded()

void de.yaacc.share.ShareKeyTracker< P >.onPlayerAdded ( P player,
Collection< String > keys )

A player became active.

Same as refresh: the player's items may be set before or after this call.

Here is the call graph for this function:

◆ onPlayerRemoved()

Set< String > de.yaacc.share.ShareKeyTracker< P >.onPlayerRemoved ( P player)

The player ended: forgets it.

Returns
the keys of this player that no other tracked player uses, i.e. the shares to release; empty for an unknown player or a second call

◆ refresh()

void de.yaacc.share.ShareKeyTracker< P >.refresh ( P player,
Collection< String > keys )

Adds keys the player is known to use now (union with what was remembered).

Malformed keys are ignored; a player that never had a key is not stored.

Referenced by de.yaacc.player.ShareLifetimeListener.itemsSet(), de.yaacc.share.ShareKeyTracker< P >.onPlayerAdded(), and de.yaacc.player.ShareLifetimeListener.onPlayerRemoving().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ trackedPlayers()

int de.yaacc.share.ShareKeyTracker< P >.trackedPlayers ( )
Returns
how many players have at least one remembered key (bookkeeping size, for tests)

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