Source code for platypush.message.event.zeroconf

import enum
from typing import Optional

from platypush.message.event import Event


[docs] class ZeroconfEventType(enum.Enum): ADD = 'add' UPDATE = 'update' REMOVE = 'remove'
[docs] class ZeroconfEvent(Event):
[docs] def __init__(self, service_event: ZeroconfEventType, service_type: str, service_name: str, service_info: Optional[dict] = None, *args, **kwargs): super().__init__(*args, service_event=service_event.value, service_type=service_type, service_name=service_name, service_info=service_info, **kwargs) self.service_type = service_type self.service_name = service_name self.service_info = service_info
[docs] class ZeroconfServiceAddedEvent(ZeroconfEvent): """ Event triggered when a service is added or discovered. """
[docs] def __init__(self, *args, **kwargs): kwargs['service_event'] = ZeroconfEventType.ADD super().__init__(*args, **kwargs)
[docs] class ZeroconfServiceUpdatedEvent(ZeroconfEvent): """ Event triggered when a service is updated. """
[docs] def __init__(self, *args, **kwargs): kwargs['service_event'] = ZeroconfEventType.UPDATE super().__init__(*args, **kwargs)
[docs] class ZeroconfServiceRemovedEvent(ZeroconfEvent): """ Event triggered when a service is removed. """
[docs] def __init__(self, *args, **kwargs): kwargs['service_event'] = ZeroconfEventType.REMOVE super().__init__(*args, **kwargs)
# vim:sw=4:ts=4:et: