U
    •uÄcÀ  ã                   @   s  d dl mZ d dlmZ d dlmZmZmZ zd dlmZ dZ	W n$ e
k
rd   dZ	d dlmZ Y nX d dlmZmZ d d	lmZmZ d
d„ ZeeƒeeƒG dd„ deƒƒƒZeeƒeeƒG dd„ deƒƒƒZeeƒeeƒG dd„ deƒƒƒZeeƒeeƒG dd„ deƒƒƒZeƒ Zeƒ ZdS )é    )Úimplementer)ÚIPlugin)Ú!IStreamServerEndpointStringParserÚIStreamServerEndpointÚIStreamClientEndpoint)Ú,IStreamClientEndpointStringParserWithReactorTF)Ú!IStreamClientEndpointStringParser)ÚserverFromStringÚclientFromString)ÚWrappingWebSocketServerFactoryÚWrappingWebSocketClientFactoryc                 C   s6  i }d| krt dƒ‚n| d |d< d| krl| d  ¡  ¡ }|dkrLd|d< n |dkr^d|d< nt d	 |¡ƒ‚d
| krÂzt| d
 ƒ}W n   t d | d
 ¡ƒ‚Y nX |dk rºt d |¡ƒ‚||d< d| krâ| d  ¡  ¡ }||d< d| k�r2| d  ¡  ¡ }|dk�rd|d< n"|dk�r$d|d< nt d |¡ƒ‚|S )NÚurlz
URL neededÚcompressionÚtrueTZenableCompressionÚfalseFz#invalid value '{0}' for compressionZautofragz invalid value '{0}' for autofragr   z!negative value '{0}' for autofragZautoFragmentSizeZsubprotocolÚdebugzinvalid value '{0}' for debug)Ú	ExceptionÚlowerÚstripÚformatÚint)ÚoptionsÚoptsÚvalue© r   úc/var/www/html/HOTSTAR/school/venv/lib/python3.8/site-packages/twisted/plugins/autobahn_endpoints.pyÚ_parseOptions0   s<    







r   c                   @   s   e Zd ZdZdd„ ZdS )ÚAutobahnServerParserÚautobahnc                 K   s   t |ƒ}t||ƒ}t|||ƒS ©N)r   r	   ÚAutobahnServerEndpoint)ÚselfÚreactorÚdescriptionr   r   Úendpointr   r   r   ÚparseStreamServerb   s    
z&AutobahnServerParser.parseStreamServerN)Ú__name__Ú
__module__Ú__qualname__Úprefixr%   r   r   r   r   r   \   s   r   c                   @   s   e Zd Zdd„ Zdd„ ZdS )r    c                 C   s   || _ || _|| _d S r   ©Ú_reactorÚ	_endpointÚ_options©r!   r"   r$   r   r   r   r   Ú__init__�   s    zAutobahnServerEndpoint.__init__c                 C   s    | j  t|fd| ji| j—Ž¡S ©Nr"   )r,   Úlistenr   r+   r-   ©r!   ZprotocolFactoryr   r   r   r1   †   s    zAutobahnServerEndpoint.listenN)r&   r'   r(   r/   r1   r   r   r   r   r    }   s   r    c                   @   s   e Zd ZdZdd„ ZdS )ÚAutobahnClientParserr   c                 O   sp   t r*|d }t|ƒdkr tdƒ‚|d }n(ddlm} t|ƒdkrJtdƒ‚|d }t|ƒ}t||ƒ}t|||ƒS )Nr   é   z=autobahn: client plugin takes exactly one positional argumenté   )r"   )Ú_HAS_REACTOR_ARGÚlenÚRuntimeErrorÚtwisted.internetr"   r   r
   ÚAutobahnClientEndpoint)r!   Úargsr   r"   r#   r   r$   r   r   r   ÚparseStreamClient’   s    

z&AutobahnClientParser.parseStreamClientN)r&   r'   r(   r)   r<   r   r   r   r   r3   �   s   r3   c                   @   s   e Zd Zdd„ Zdd„ ZdS )r:   c                 C   s   || _ || _|| _d S r   r*   r.   r   r   r   r/   ¦   s    zAutobahnClientEndpoint.__init__c                 C   s    | j  t|fd| ji| j—Ž¡S r0   )r,   Úconnectr   r+   r-   r2   r   r   r   r=   «   s    zAutobahnClientEndpoint.connectN)r&   r'   r(   r/   r=   r   r   r   r   r:   ¢   s   r:   N)Zzope.interfacer   Útwisted.pluginr   Ztwisted.internet.interfacesr   r   r   r   r6   ÚImportErrorr   Ztwisted.internet.endpointsr	   r
   Zautobahn.twisted.websocketr   r   r   Úobjectr   r    r3   r:   ZautobahnServerParserZautobahnClientParserr   r   r   r   Ú<module>   s2   ,