spotifywebapipython.spotifyconnect.spotifyconnectzeroconflistener

ZEROCONF_SERVICETYPE_SPOTIFYCONNECT: str = '_spotify-connect._tcp.local.'

Spotify Connect Zeroconf service type identifier.

class SpotifyConnectZeroconfListener:

Spotify Connect Zeroconf Listener class.

Listens for Chromecast device connection updates for devices that support Spotify Connect.

SpotifyConnectZeroconfListener(parentDirectory, zeroconf_RLock: <function RLock>)

Initializes a new instance of the class.

Arguments:
  • parentDirectory (SpotifyConnectDirectoryTask): Parent SpotifyConnectDirectoryTask instance.
  • zeroconf_RLock (threading.RLock): Lock object used to enforce thread-safe updates.
def OnServiceStateChange( self, zeroconf: zeroconf._core.Zeroconf, service_type: str, name: str, state_change: zeroconf._services.ServiceStateChange) -> None:

Called by the spotify connect zeroconf ServiceBrowser when an mDNS service state has changed (e.g. added, removed, or updated).

Arguments:
  • zeroconf (Zeroconf): Zeroconf instance that raised the notification.
  • service_type (str): Service type that was affected.
  • name (str): Service name that was affected.
  • state_change (ServiceStateChange): The type of service state change (add, remove, update).
def add_service( self, zeroconf: zeroconf._core.Zeroconf, serviceType: str, serviceName: str, serviceStateChange: zeroconf._services.ServiceStateChange) -> None:

Called when an mDNS service is discovered.

Arguments:
  • zeroconf (Zeroconf): Zeroconf instance that raised the notification.
  • serviceType (str): Service type that was affected.
  • serviceName (str): Service name that was affected.
  • serviceStateChange (ServiceStateChange): A description of the type of service state change (add, remove, update).

This method will be called in a thread-safe manner, as the caller is using the Zeroconf_RLock object to control access.

def remove_service( self, zeroconf: zeroconf._core.Zeroconf, serviceType: str, serviceName: str, serviceStateChange: zeroconf._services.ServiceStateChange) -> None:

Called when an mDNS service is lost.

Arguments:
  • zeroconf (Zeroconf): Zeroconf instance that raised the notification.
  • serviceType (str): Service type that was affected.
  • serviceName (str): Service name that was affected.
  • serviceStateChange (ServiceStateChange): A description of the type of service state change (add, remove, update).

This method will be called in a thread-safe manner, as the caller is using the Zeroconf_RLock object to control access.

def update_service( self, zeroconf: zeroconf._core.Zeroconf, serviceType: str, serviceName: str, serviceStateChange: zeroconf._services.ServiceStateChange) -> None:

Called when an mDNS service is updated.

Arguments:
  • zeroconf (Zeroconf): Zeroconf instance that raised the notification.
  • serviceType (str): Service type that was affected.
  • serviceName (str): Service name that was affected.
  • serviceStateChange (ServiceStateChange): A description of the type of service state change (add, remove, update).

This method will be called in a thread-safe manner, as the caller is using the Zeroconf_RLock object to control access.