YAACC - UPNP Client and Server
Loading...
Searching...
No Matches
de.yaacc.multiroom.discovery.ResolveQueue< T > Class Template Reference

The services that wait to be resolved. More...

Collaboration diagram for de.yaacc.multiroom.discovery.ResolveQueue< T >:
Collaboration graph

Classes

class  Pending
 A service that waits for, or is in, resolution.
 

Public Member Functions

 ResolveQueue (MonotonicClock clock, long timeoutMillis, int capacity)
 
synchronized boolean offer (String name, T item)
 Queues a service.
 
synchronized Pending< T > next ()
 The service to resolve now, or null when one is being resolved (and has time left) or none waits.
 
synchronized void done (Pending< T > pending)
 The resolution that was started with this entry ended (answer or failure).
 
synchronized void done (String name)
 The resolution of this name ended (answer or failure); an answer for any other name is ignored.
 
synchronized void clear ()
 Forgets everything (discovery stopped).
 
synchronized int size ()
 

Detailed Description

The services that wait to be resolved.

Android's NsdManager resolves one service at a time (a second request fails with "already active"), a resolution can stay unanswered, and a hostile network can announce any number of names. So: a bounded first-in-first-out queue, one active entry, the same name queued once, and an active entry that was not answered within the timeout is given up. Pure; the thin Android wrapper only asks it what to do.

Parameters
<T>what the wrapper needs to start a resolution (the service info object)

Member Function Documentation

◆ done()

synchronized void de.yaacc.multiroom.discovery.ResolveQueue< T >.done ( Pending< T > pending)

The resolution that was started with this entry ended (answer or failure).

Only the entry that is active now is cleared: the late answer of a resolution that was dropped (the discovery was stopped, or the timeout gave it up) must not clear a newer resolution of the same name.

◆ next()

synchronized Pending< T > de.yaacc.multiroom.discovery.ResolveQueue< T >.next ( )

The service to resolve now, or null when one is being resolved (and has time left) or none waits.

The caller starts the resolution and calls done when it ends; call this again after done and now and then, so that an unanswered resolution is given up.

◆ offer()

synchronized boolean de.yaacc.multiroom.discovery.ResolveQueue< T >.offer ( String name,
T item )

Queues a service.

A name that is queued already gets the newer item; a name that is being resolved is not queued again.

Returns
false if the service was dropped because the queue is full or the name is empty

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