§
    8jç  ã                  óž   — d Z ddlmZ ddlZddlmZ ddlmZ ddlm	Z	m
Z
 dd	lmZmZmZmZ ej        Zerdd
lmZ eZeZ G d„ d¦  «        ZdS )a‡  Multicast DNS Service Discovery for Python, v0.14-wmcbrine
Copyright 2003 Paul Scott-Murphy, 2014 William McBrine

This module provides a framework for the use of DNS Service Discovery
using IP multicast.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
USA
é    )ÚannotationsN)Údeque)ÚTYPE_CHECKINGé   )Úcurrent_time_millisÚmillis_to_secondsé   )ÚMULTICAST_DELAY_RANDOM_INTERVALÚAnswerGroupÚ_AnswerWithAdditionalsTypeÚ$construct_outgoing_multicast_answers)ÚZeroconfc                  ó6   — e Zd ZdZdZdd
„Zdd„Zdd„Zdd„ZdS )ÚMulticastOutgoingQueuez8An outgoing queue used to aggregate multicast responses.)Ú_additional_delayÚ_aggregation_delayÚ_multicast_delay_random_maxÚ_multicast_delay_random_minÚqueueÚzcÚzeroconfr   Úadditional_delayÚ_intÚmax_aggregation_delayÚreturnÚNonec                óž   — || _         t          ¦   «         | _        t          d         | _        t          d         | _        || _        || _        d S )Nr   r	   )r   r   r   r
   r   r   r   r   )Úselfr   r   r   s       úa/home/user/adhan/venv/lib/python3.11/site-packages/zeroconf/_handlers/multicast_outgoing_queue.pyÚ__init__zMulticastOutgoingQueue.__init__:   sG   € ØˆŒÝ).©¬ˆŒ
õ ,KÈ1Ô+MˆÔ(Ý+JÈ1Ô+MˆÔ(Ø!1ˆÔØ"7ˆÔÐÐó    ÚnowÚ_floatÚanswersr   c                ó  — | j         j        }t          r|€J ‚t          | j        | j        ¦  «        }|| j        z   }||z   }|| j        z   | j        z   }t          | j	        ¦  «        r5| j	        d         }||j
        k    r|j                             |¦  «         dS n=|                     |                     ¦   «         t          |¦  «        z   | j        ¦  «         | j	                             t%          |||¦  «        ¦  «         dS )z>Add a group of answers with additionals to the outgoing queue.Néÿÿÿÿ)r   Úloopr   ÚRAND_INTr   r   r   r   Úlenr   Ú
send_afterr$   ÚupdateÚcall_atÚtimer   Úasync_readyÚappendr   )	r   r"   r$   r'   Ú
random_intÚrandom_delayr*   Úsend_beforeÚ
last_groups	            r   Ú	async_addz MulticastOutgoingQueue.async_addE   s  € àŒwŒ|ˆÝð 	$ØÐ#Ð#Ð#Ý˜dÔ>ÀÔ@`ÑaÔaˆ
Ø! DÔ$:Ñ:ˆØ˜<Ñ'ˆ
Ø˜DÔ3Ñ3°dÔ6LÑLˆÝˆtŒz‰?Œ?ð 
	Zð
 œ BœˆJØ˜ZÔ2Ò2Ð2ØÔ"×)Ò)¨'Ñ2Ô2Ð2Øð 3ð LŠL˜Ÿš™œÕ'8¸Ñ'FÔ'FÑFÈÔHXÑYÔYÐYØŒ
×Ò+ j°+¸wÑGÔGÑHÔHÐHÐHÐHr!   c                óZ   — | j         D ]"}|D ]}|j                             |d¦  «         ŒŒ#dS )z0Remove a set of answers from the outgoing queue.N)r   r$   Úpop)r   r$   ÚpendingÚrecords       r   Ú_remove_answers_from_queuez1MulticastOutgoingQueue._remove_answers_from_queue[   sL   € à”zð 	2ð 	2ˆGØ!ð 2ð 2Ø”×#Ò# F¨DÑ1Ô1Ð1Ð1ð2ð	2ð 	2r!   c                ó   — | j         }|j        }t          r|€J ‚t          ¦   «         }t	          | j        ¦  «        dk    rh| j        d         j        |k    rR|                     |                     ¦   «         t          | j        d         j        |z
  ¦  «        z   | j
        ¦  «         dS i }t	          | j        ¦  «        rq| j        d         j        |k    r[|                     | j                             ¦   «         j        ¦  «         t	          | j        ¦  «        r| j        d         j        |k    °[t	          | j        ¦  «        rP|                     |                     ¦   «         t          | j        d         j        |z
  ¦  «        z   | j
        ¦  «         |r9|                      |¦  «         |                     t#          |¦  «        ¦  «         dS dS )z,Process anything in the queue that is ready.Nr	   r   )r   r'   r   r   r)   r   r2   r,   r-   r   r.   r*   r+   Úpopleftr$   r9   Ú
async_sendr   )r   r   r'   r"   r$   s        r   r.   z"MulticastOutgoingQueue.async_readya   s´  € àŒWˆØŒwˆÝð 	$ØÐ#Ð#Ð#Ý!Ñ#Ô#ˆåˆtŒz‰?Œ?˜QÒÐ 4¤:¨a¤=Ô#<¸sÒ#BÐ#Bð LŠLØ—	’	‘”Õ/°´
¸1´Ô0IÈCÑ0OÑPÔPÑPØÔ ñô ð ð ˆFà.0ˆå$”*‰oŒoð 	9 $¤*¨Q¤-Ô":¸cÒ"AÐ"AØNŠN˜4œ:×-Ò-Ñ/Ô/Ô7Ñ8Ô8Ð8õ $”*‰oŒoð 	9 $¤*¨Q¤-Ô":¸cÒ"AÐ"Aõ ˆtŒz‰?Œ?ð 	ð LŠLØ—	’	‘”Õ/°´
¸1´Ô0HÈ3Ñ0NÑOÔOÑOØÔ ñô ð ð
 ð 	Ià×+Ò+¨GÑ4Ô4Ð4ØMŠMÕ>¸wÑGÔGÑHÔHÐHÐHÐHð	Ið 	Ir!   N)r   r   r   r   r   r   r   r   )r"   r#   r$   r   r   r   )r$   r   r   r   )r   r   )	Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r    r4   r9   r.   © r!   r   r   r   .   s{   € € € € € ØBÐBð€Ið	8ð 	8ð 	8ð 	8ðIð Ið Ið Ið,2ð 2ð 2ð 2ð!Ið !Ið !Ið !Ið !Ið !Ir!   r   )r@   Ú
__future__r   ÚrandomÚcollectionsr   Útypingr   Ú_utils.timer   r   r$   r
   r   r   r   Úrandintr(   Ú_corer   Úfloatr#   Úintr   r   rB   r!   r   ú<module>rL      s  ððð ð, #Ð "Ð "Ð "Ð "Ð "à €€€Ø Ð Ð Ð Ð Ð Ø  Ð  Ð  Ð  Ð  Ð  à @Ð @Ð @Ð @Ð @Ð @Ð @Ð @ðð ð ð ð ð ð ð ð ð ð ð ð Œ>€àð !Ø Ð Ð Ð Ð Ð à	€Ø
€ðTIð TIð TIð TIð TIñ TIô TIð TIð TIð TIr!   