mirror of
https://github.com/EyeTrackVR/OpenIris.git
synced 2025-11-04 15:39:42 +08:00
MDNS python example (#10)
* Add MDNS support * Fix typo preventing mdns from connecting
This commit is contained in:
parent
a460c81c6c
commit
2177032eed
23
PythonExamples/mdns.py
Normal file
23
PythonExamples/mdns.py
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
from zeroconf import Zeroconf, ServiceListener, ServiceBrowser
|
||||||
|
|
||||||
|
|
||||||
|
class Listener(ServiceListener):
|
||||||
|
def add_service(self, zc: "Zeroconf", type_: str, name: str) -> None:
|
||||||
|
info = zc.get_service_info(type_, name)
|
||||||
|
print(f"Service {name} added, service info: {info}")
|
||||||
|
print(f"Address {info.parsed_addresses()}")
|
||||||
|
print(f"Port {info.port}")
|
||||||
|
|
||||||
|
def remove_service(self, zc: "Zeroconf", type_: str, name: str) -> None:
|
||||||
|
print(f"Service {name} removed")
|
||||||
|
|
||||||
|
def update_service(self, zc: "Zeroconf", type_: str, name: str) -> None:
|
||||||
|
print(f"Service {name} updated")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
zconf = Zeroconf()
|
||||||
|
cameraListener = Listener()
|
||||||
|
browser = ServiceBrowser(zconf, "_openIrisTracker._tcp.local.", cameraListener)
|
||||||
|
input("Press enter to close... \n")
|
||||||
|
zconf.close()
|
||||||
33
PythonExamples/poetry.lock
generated
Normal file
33
PythonExamples/poetry.lock
generated
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
[[package]]
|
||||||
|
name = "ifaddr"
|
||||||
|
version = "0.1.7"
|
||||||
|
description = "Cross-platform network interface and IP address enumeration library"
|
||||||
|
category = "main"
|
||||||
|
optional = false
|
||||||
|
python-versions = "*"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "zeroconf"
|
||||||
|
version = "0.38.4"
|
||||||
|
description = "Pure Python Multicast DNS Service Discovery Library (Bonjour/Avahi compatible)"
|
||||||
|
category = "main"
|
||||||
|
optional = false
|
||||||
|
python-versions = "*"
|
||||||
|
|
||||||
|
[package.dependencies]
|
||||||
|
ifaddr = ">=0.1.7"
|
||||||
|
|
||||||
|
[metadata]
|
||||||
|
lock-version = "1.1"
|
||||||
|
python-versions = "^3.8"
|
||||||
|
content-hash = "944b5c3bc6e6b85421323bd76ae236e8fcd4a11a69220aff396ec91a557f7ba0"
|
||||||
|
|
||||||
|
[metadata.files]
|
||||||
|
ifaddr = [
|
||||||
|
{file = "ifaddr-0.1.7-py2.py3-none-any.whl", hash = "sha256:d1f603952f0a71c9ab4e705754511e4e03b02565bc4cec7188ad6415ff534cd3"},
|
||||||
|
{file = "ifaddr-0.1.7.tar.gz", hash = "sha256:1f9e8a6ca6f16db5a37d3356f07b6e52344f6f9f7e806d618537731669eb1a94"},
|
||||||
|
]
|
||||||
|
zeroconf = [
|
||||||
|
{file = "zeroconf-0.38.4-py3-none-any.whl", hash = "sha256:f5dd86d12d06d1eec9fad05778d3c5787c2bcc03df4de4728b938df6bff70129"},
|
||||||
|
{file = "zeroconf-0.38.4.tar.gz", hash = "sha256:080c540ea4b8b9defa9f3ac05823c1725ea2c8aacda917bfc0193f6758b95aeb"},
|
||||||
|
]
|
||||||
16
PythonExamples/pyproject.toml
Normal file
16
PythonExamples/pyproject.toml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
[tool.poetry]
|
||||||
|
name = "pythonexamples"
|
||||||
|
version = "0.1.0"
|
||||||
|
description = ""
|
||||||
|
authors = ["lorow <smykupyka@gmail.com>"]
|
||||||
|
license = "gnu gplv3"
|
||||||
|
|
||||||
|
[tool.poetry.dependencies]
|
||||||
|
python = "^3.8"
|
||||||
|
zeroconf = "^0.38.4"
|
||||||
|
|
||||||
|
[tool.poetry.dev-dependencies]
|
||||||
|
|
||||||
|
[build-system]
|
||||||
|
requires = ["poetry-core>=1.0.0"]
|
||||||
|
build-backend = "poetry.core.masonry.api"
|
||||||
Loading…
Reference in New Issue
Block a user