o
    BŠ]¾  ã                   @   sZ   d dl Z d dlmZ d dlmZ d dlmZ d dlmZ d dl	m
Z
 G dd„ deeƒZdS )	é    N)ÚDatagramProtocol)Úreactor)ÚAbstractTwistedTransport)Úerror)Údebugc                   @   s0   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
S )ÚDgramTwistedTransportzBBase Twisted datagram Transport, to be used with TwistedDispatcherc                 C   s,   | j d u r
t d¡‚t d| j | ||¡ d S )NzUnable to call cbFunr   )Z_cbFunr   ÚCarrierErrorr   Z	callLater)ÚselfZdatagramÚtransportAddress© r   úC/usr/lib/python3/dist-packages/pysnmp/carrier/twisted/dgram/base.pyÚdatagramReceived   s   

z&DgramTwistedTransport.datagramReceivedc                 C   s˜   t jt j@ o
t  d¡ | jrJ| j d¡\}}t jt j@ o't  d|t  |¡f ¡ z	| j ||¡ W n tyD   t	 
dt ¡ d f ¡‚w | jsd S d S )NzstartProtocol: invokedr   z5startProtocol: transportAddress %r outgoingMessage %súTwisted exception: %sé   )r   ÚloggerÚflagIOÚ_writeQÚpopÚhexdumpÚ	transportÚwriteÚ	Exceptionr   r   ÚsysÚexc_info©r	   ZoutgoingMessager
   r   r   r   ÚstartProtocol   s   €"€ÿûz#DgramTwistedTransport.startProtocolc                 C   s    t jt j@ ot  d¡ d S  d S )NzstopProtocol: invoked)r   r   r   )r	   r   r   r   ÚstopProtocol&   s    z"DgramTwistedTransport.stopProtocolc                 C   sŽ   t jt j@ ot  d| jd u rdpd|t  |¡f ¡ | jd u r)| j ||f¡ d S z
| j ||¡ W d S  tyF   t	 
dt ¡ d f ¡‚w )Nz8startProtocol: %s transportAddress %r outgoingMessage %sZqueuingZsendingr   r   )r   r   r   r   r   r   Úappendr   r   r   r   r   r   r   r   r   r   ÚsendMessage)   s   2€
ÿz!DgramTwistedTransport.sendMessageN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r   r      s    
r   )r   Ztwisted.internet.protocolr   Ztwisted.internetr   Zpysnmp.carrier.twisted.baser   Zpysnmp.carrierr   Zpysnmpr   r   r   r   r   r   Ú<module>   s   