YAACC - UPNP Client and Server
Loading...
Searching...
No Matches
de.yaacc.browser.DeviceSessionGrouper Class Reference

Groups running player sessions under the receiver device they play on. More...

Collaboration diagram for de.yaacc.browser.DeviceSessionGrouper:
Collaboration graph

Classes

class  PlayerRef
 Android-free snapshot of a running player: its id (identity only, used to look the player up again), the id of the device it plays on (Player#getDeviceId()), whether it is currently playing, and its creation sequence (PlayerService#getPlayerCreationSequence), where higher means added later.
 
class  Row
 One row of the grouped list: either a receiver or a player session.
 

Static Public Member Functions

static List< Row > group (List< String > receiverDeviceIds, List< PlayerRef > players)
 Receivers in the given order, each followed by its sessions, oldest first (ascending creation sequence); sessions with an unknown deviceId go last, grouped per device.
 
static PlayerRef primarySession (String deviceId, List< PlayerRef > players)
 Among the device's playing sessions, the newest (highest creation sequence); if none is playing, the newest session overall; null if the device has no sessions.
 

Detailed Description

Groups running player sessions under the receiver device they play on.

Receivers and players are not 1:1 (a device can run several players at once), so the result is an ordered list of receiver rows, each followed by zero or more session rows.

Deliberately has no android.* imports - same testability precedent as CardGridSpanCount - so it can be unit-tested on the plain JVM without Robolectric.

Device ids come from untrusted LAN devices (SSDP/UDN), so they are treated as opaque strings: UpnpClient.LOCAL_UID gets no special handling, a duplicate receiver id is only listed at its first occurrence, and a null id never throws.

Member Function Documentation

◆ group()

static List< Row > de.yaacc.browser.DeviceSessionGrouper.group ( List< String > receiverDeviceIds,
List< PlayerRef > players )
static

Receivers in the given order, each followed by its sessions, oldest first (ascending creation sequence); sessions with an unknown deviceId go last, grouped per device.

Never drops a session.

Unknown-device sessions get no RECEIVER row (the caller labels them from Row#deviceId()); their device groups are ordered by each group's oldest session. Equal sequences fall back to playerId so the result never depends on input order. A duplicate receiver id is listed only at its first occurrence, a null receiver id is skipped, and sessions with a null deviceId form their own trailing group. With no receivers at all, every session is still listed. null lists are treated as empty.

◆ primarySession()

static PlayerRef de.yaacc.browser.DeviceSessionGrouper.primarySession ( String deviceId,
List< PlayerRef > players )
static

Among the device's playing sessions, the newest (highest creation sequence); if none is playing, the newest session overall; null if the device has no sessions.

Independent of input order (players arrive in HashMap order); equal sequences fall back to the higher playerId.


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