Skip to content

Commit a365b50

Browse files
Adds get_service_types to mdns class
1 parent dfd560e commit a365b50

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/python_testing/mdns_discovery/mdns_discovery.py

+23
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,29 @@ async def get_all_services(self, log_output: bool = False,
232232

233233
return self._discovered_services
234234

235+
async def get_service_types(self, log_output: bool = False) -> List[str]:
236+
"""
237+
Asynchronously discovers all available mDNS services within the network and returns a list
238+
of the service types discovered. This method utilizes the AsyncZeroconfServiceTypes.async_find()
239+
function to perform the network scan for mDNS services.
240+
241+
Args:
242+
log_output (bool): If set to True, the discovered service types are logged to the console.
243+
This can be useful for debugging or informational purposes. Defaults to False.
244+
245+
Returns:
246+
List[str]: A list containing the service types (str) of the discovered mDNS services. Each
247+
element in the list is a string representing a unique type of service found during
248+
the discovery process.
249+
"""
250+
251+
discovered_services = list(await AsyncZeroconfServiceTypes.async_find())
252+
253+
if log_output:
254+
print(f"MDNS discovered service types: {discovered_services}")
255+
256+
return discovered_services
257+
235258
# Private methods
236259
async def _discover(self,
237260
discovery_timeout_sec: float,

0 commit comments

Comments
 (0)