o
    >hJ                     @   s  d dl mZmZ d dlmZ d dlmZ d dlZe  d dl	Z
d dlmZ d dlmZ d dlmZmZmZ d dlmZ d d	lmZ d d
l	mZ d dlmZmZmZ d dlmZmZ d dlmZ d dl m!Z! d dl"m#Z#m$Z$m%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/m0Z0m1Z1 dZ2dd Z3dd Z4dd Z5dd Z6G dd de)Z7G dd  d e
j8j'j9Z:eG d!d" d"e:e'j;Z;eG d#d$ d$e:e'j<Z<G d%d& d&e=Z>eG d'd( d(e>e'j?e
j8j'j@Z?eG d)d* d*e>e'jAe
j8j'jBZAeeG d+d, d,e=ZCG d-d. d.eCe;ZDG d/d0 d0eCe<ZEG d1d2 d2e?ZFG d3d4 d4eAZGedDd6d7ZHedEd:d;ZIeG d<d= d=ejJe;ZJeG d>d? d?ejKe?ZKeG d@dA dAejLe<ZLeG dBdC dCejMeAZMdS )F    )	b64encode	b64decode)Optional)implementerN)	endpoints)
ITransport)ConnectionDoneConnectionAbortedConnectionLost)Deferred)Failure)connectionDone)publichltypehlval)_is_tls_error_maybe_tls_reason)	websocket)TransportDetails)ConnectionRequestConnectionResponseConnectionDeny)protocol)IWebSocketClientAgent)create_transport_detailstransport_channel_id)PerMessageDeflateOfferPerMessageDeflateOfferAcceptPerMessageDeflateResponsePerMessageDeflateResponseAccept)create_client_agentWebSocketAdapterProtocolWebSocketServerProtocolWebSocketClientProtocolWebSocketAdapterFactoryWebSocketServerFactoryWebSocketClientFactoryWrappingWebSocketAdapterWrappingWebSocketServerProtocolWrappingWebSocketClientProtocolWrappingWebSocketServerFactoryWrappingWebSocketClientFactorylistenWS	connectWSWampWebSocketServerProtocolWampWebSocketServerFactoryWampWebSocketClientProtocolWampWebSocketClientFactoryc                 C   s   t | S )zB
    :returns: an instance implementing IWebSocketClientAgent
    )_TwistedWebSocketClientAgentreactor r5   z/var/www/vedio/testing/chatpythonscript.ninositsolution.com/env/lib/python3.10/site-packages/autobahn/twisted/websocket.pyr    V   s   r    c                 C   s<   t | tstdt| | ds| dstddS )z>
    raises a ValueError if `transport_config` is invalid
    z-'transport_config' must be a string, found {}zws://zwss://z6'transport_config' must start with 'ws://' or 'wss://'N)
isinstancestr
ValueErrorformattype
startswith)transport_configr5   r5   r6   check_transport_config]   s   

r>   c                 C   sB   t | ts	tdg d}|  D ]}||vrtd|qdS )z5
    raises a ValueError if `options` is invalid
    z'options' must be a dict)origin	protocols	useragentheadersproxyz'options' may not contain '{}'N)r7   dictr9   keysr:   )options
valid_keysactual_kr5   r5   r6   check_client_optionsq   s   
rI   c                 C   s   |j rddlm} ||j}|jd ur&||_t| |jd |jd }|S |j r;ddlm} t	| |j|j
|}|S t| |j|j
}|S )Nr   sslhostport)isSecuretwisted.internetrK   optionsForClientTLSrL   rC   contextFactoryr   HostnameEndpointSSL4ClientEndpointrM   )r4   factoryr=   rF   rK   context_factoryendpointr5   r5   r6   _endpoint_from_config   s4   
rW   c                   @   s"   e Zd ZdZdd ZdddZdS )r2   z6
    This agent creates connections using Twisted
    c                 C   s
   || _ d S N)_reactor)selfr4   r5   r5   r6   __init__   s   
z%_TwistedWebSocketClientAgent.__init__Nc                    s   t | t| td|| jd|}|du rtn||_t| j|||}t ||}fdd  fdd}|	|  S )a-  
        Open a new connection.

        :param dict transport_config: valid transport configuration

        :param dict options: additional options for the factory

        :param protocol_class: a callable that returns an instance of
            the protocol (WebSocketClientProtocol if the default None
            is passed in)

        :returns: a Deferred that fires with an instance of
            `protocol_class` (or WebSocketClientProtocol by default)
            that has successfully shaken hands (completed the
            handshake).
        )urlr4   Nc                    s     |  d S rX   )errback)f)rtn_dr5   r6   failed      z1_TwistedWebSocketClientAgent.open.<locals>.failedc                    s     fdd} j |  S )Nc                    s      | S rX   )callback)arg)protor_   r5   r6   handshake_completed   s   
zQ_TwistedWebSocketClientAgent.open.<locals>.got_proto.<locals>.handshake_completed)is_openaddCallbacks)rd   re   r`   r_   )rd   r6   	got_proto   s   z4_TwistedWebSocketClientAgent.open.<locals>.got_protor5   )
r>   rI   r&   rY   r#   r   rW   r   connectrg   )rZ   r=   rF   protocol_classrT   rV   proto_dri   r5   rh   r6   open   s    
z!_TwistedWebSocketClientAgent.openrX   )__name__
__module____qualname____doc__r[   rm   r5   r5   r5   r6   r2      s    r2   c                   @   s   e Zd ZU dZe ZdZee	 e
d< dZee e
d< dd Zefdefdd	Zd
efddZd*ddZdd Zdd Zdd Zdd Zdd Zdd Zdd Zdd Zd d! Zd"d# Zd$d% Zd&d' Zd(d) Z dS )+r!   a  
    Adapter class for Twisted WebSocket client and server protocols.

    Called from Twisted:

    * :meth:`autobahn.twisted.websocket.WebSocketAdapterProtocol.connectionMade`
    * :meth:`autobahn.twisted.websocket.WebSocketAdapterProtocol.connectionLost`
    * :meth:`autobahn.twisted.websocket.WebSocketAdapterProtocol.dataReceived`

    Called from Network-independent Code (WebSocket implementation):

    * :meth:`autobahn.twisted.websocket.WebSocketAdapterProtocol._onOpen`
    * :meth:`autobahn.twisted.websocket.WebSocketAdapterProtocol._onMessageBegin`
    * :meth:`autobahn.twisted.websocket.WebSocketAdapterProtocol._onMessageFrameData`
    * :meth:`autobahn.twisted.websocket.WebSocketAdapterProtocol._onMessageFrameEnd`
    * :meth:`autobahn.twisted.websocket.WebSocketAdapterProtocol._onMessageEnd`
    * :meth:`autobahn.twisted.websocket.WebSocketAdapterProtocol._onMessage`
    * :meth:`autobahn.twisted.websocket.WebSocketAdapterProtocol._onPing`
    * :meth:`autobahn.twisted.websocket.WebSocketAdapterProtocol._onPong`
    * :meth:`autobahn.twisted.websocket.WebSocketAdapterProtocol._onClose`

    FIXME:

    * :meth:`autobahn.twisted.websocket.WebSocketAdapterProtocol._closeConnection`
    * :meth:`autobahn.twisted.websocket.WebSocketAdapterProtocol._create_transport_details`
    * :meth:`autobahn.twisted.websocket.WebSocketAdapterProtocol.registerProducer`
    * :meth:`autobahn.twisted.websocket.WebSocketAdapterProtocol.unregisterProducer`
    Npeer	is_serverc                 C   sj   t | j| j| _tj| j_| jj| _z	| j| j	 W n   Y | 
  | jjdt| jt| jd d S )Nz/{func} connection established for peer="{peer}"funcrr   )r   	transportrs   _transport_detailsr   CHANNEL_FRAMING_WEBSOCKETchannel_framingrr   setTcpNoDelay
tcpNoDelay_connectionMadelogdebugr   connectionMader   rZ   r5   r5   r6   r     s   


z'WebSocketAdapterProtocol.connectionMadereasonc                 C   s  d}t |jtr| jjd| jd d}nNt|jr#| jt|j n?t |jt	r3| jjd| jd n/t |jt
rSt|j}t|jdrH|jj}| jjd| j|d n| jjd	| jt|j|jd
 | | |rz| jjdt| jt| jd d S | jjdt| jt| j|d d S )NFz,Connection to/from {peer} was closed cleanly)rr   Tz-Connection to/from {peer} was aborted locallymessagezDConnection to/from {peer} was lost in a non-clean fashion: {message})rr   r   z7Connection to/from {peer} lost ({error_type}): {error}))rr   
error_typeerrorz8{func} connection lost for peer="{peer}", closed cleanlyrt   zD{func} connection lost for peer="{peer}", closed with error {reason})ru   rr   r   )r7   valuer   r}   r~   rr   r   r   r   r	   r
   r8   hasattrr   r;   _connectionLostr   connectionLostr   )rZ   r   	was_cleanr   r5   r5   r6   r   '  sF   




z'WebSocketAdapterProtocol.connectionLostdatac                 C   s6   | j jdt| jt| jtt|d | | d S )Nz2{func} received {data_len} bytes for peer="{peer}")ru   rr   data_len)r}   r~   r   dataReceivedr   rr   len_dataReceivedrZ   r   r5   r5   r6   r   U  s   
z%WebSocketAdapterProtocol.dataReceivedFc                 C   s,   |rt | jdr| j  d S | j  d S )NabortConnection)r   rv   r   loseConnection)rZ   abortr5   r5   r6   _closeConnection^  s   z)WebSocketAdapterProtocol._closeConnectionc                 C   s2   | j jrdt| j| j jdi}|| j _|   d S )Nz
tls-unique)rw   	is_securer   rv   rs   
channel_idonOpen)rZ   r   r5   r5   r6   _onOpene  s
   z WebSocketAdapterProtocol._onOpenc                 C      |  | d S rX   )onMessageBegin)rZ   isBinaryr5   r5   r6   _onMessageBeginp  ra   z(WebSocketAdapterProtocol._onMessageBeginc                 C   r   rX   )onMessageFrameBegin)rZ   lengthr5   r5   r6   _onMessageFrameBegins  ra   z-WebSocketAdapterProtocol._onMessageFrameBeginc                 C   r   rX   )onMessageFrameDatarZ   payloadr5   r5   r6   _onMessageFrameDatav  ra   z,WebSocketAdapterProtocol._onMessageFrameDatac                 C      |    d S rX   )onMessageFrameEndr   r5   r5   r6   _onMessageFrameEndy     z+WebSocketAdapterProtocol._onMessageFrameEndc                 C   r   rX   )onMessageFramer   r5   r5   r6   _onMessageFrame|  ra   z(WebSocketAdapterProtocol._onMessageFramec                 C   r   rX   )onMessageEndr   r5   r5   r6   _onMessageEnd  r   z&WebSocketAdapterProtocol._onMessageEndc                 C   s   |  || d S rX   )	onMessage)rZ   r   r   r5   r5   r6   
_onMessage     z#WebSocketAdapterProtocol._onMessagec                 C   r   rX   )onPingr   r5   r5   r6   _onPing  ra   z WebSocketAdapterProtocol._onPingc                 C   r   rX   )onPongr   r5   r5   r6   _onPong  ra   z WebSocketAdapterProtocol._onPongc                 C   s   |  ||| d S rX   )onCloserZ   wasCleancoder   r5   r5   r6   _onClose  s   z!WebSocketAdapterProtocol._onClosec                 C   s   | j || dS )z
        Register a Twisted producer with this protocol.

        :param producer: A Twisted push or pull producer.
        :type producer: object
        :param streaming: Producer type.
        :type streaming: bool
        N)rv   registerProducer)rZ   producer	streamingr5   r5   r6   r     s   	z)WebSocketAdapterProtocol.registerProducerc                 C   s   | j   dS )zA
        Unregister Twisted producer with this protocol.
        N)rv   unregisterProducerr   r5   r5   r6   r     s   z+WebSocketAdapterProtocol.unregisterProducer)F)!rn   ro   rp   rq   txaiomake_loggerr}   rr   r   r8   __annotations__rs   boolr   r   r   r   bytesr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r5   r5   r5   r6   r!      s,   
 .
	r!   c                   @   s   e Zd ZdZe ZdZdS )r"   z
    Base class for Twisted-based WebSocket server protocols.

    Implements :class:`autobahn.websocket.interfaces.IWebSocketChannel`.
    TN)rn   ro   rp   rq   r   r   r}   rs   r5   r5   r5   r6   r"     s    r"   c                   @   s2   e Zd ZdZe ZdZdefddZ	dd Z
dS )	r#   z
    Base class for Twisted-based WebSocket client protocols.

    Implements :class:`autobahn.websocket.interfaces.IWebSocketChannel`.
    Fresponsec                 C   s"   | j jdt| j|d | |S )Nz{meth}(response={response}))methr   )r}   r~   r   
_onConnect	onConnect)rZ   r   r5   r5   r6   r     s   
z"WebSocketClientProtocol._onConnectc                 C   s    | j d | j| jj d S )NzStarting TLS upgrade)r}   r~   rv   startTLSrT   rQ   r   r5   r5   r6   r     s   z WebSocketClientProtocol.startTLSN)rn   ro   rp   rq   r   r   r}   rs   r   r   r   r5   r5   r5   r6   r#     s    r#   c                   @      e Zd ZdZdS )r$   zP
    Adapter class for Twisted-based WebSocket client and server factories.
    Nrn   ro   rp   rq   r5   r5   r5   r6   r$         r$   c                   @       e Zd ZdZe Zdd ZdS )r%   z
    Base class for Twisted-based WebSocket server factories.

    Implements :class:`autobahn.websocket.interfaces.IWebSocketServerChannelFactory`
    c                 O   sD   | dd}|du rddlm} || _tjj| g|R i | dS )a  

        .. note::
            In addition to all arguments to the constructor of
            :meth:`autobahn.websocket.interfaces.IWebSocketServerChannelFactory`,
            you can supply a ``reactor`` keyword argument to specify the
            Twisted reactor to be used.
        r4   Nr   r3   )poprO   r4   r   r%   r[   )rZ   argskwargsr4   r5   r5   r6   r[     s
   
zWebSocketServerFactory.__init__Nrn   ro   rp   rq   r   r   r}   r[   r5   r5   r5   r6   r%         r%   c                   @   r   )r&   z
    Base class for Twisted-based WebSocket client factories.

    Implements :class:`autobahn.websocket.interfaces.IWebSocketClientChannelFactory`
    c                 O   sv   | dd}|du rddlm} || _tjj| g|R i | | jr7| jdur9ddlm} |	| j
| _dS dS dS )a  

        .. note::
            In addition to all arguments to the constructor of
            :func:`autobahn.websocket.interfaces.IWebSocketClientChannelFactory`,
            you can supply a ``reactor`` keyword argument to specify the
            Twisted reactor to be used.
        r4   Nr   r3   rJ   )r   rO   r4   r   r&   r[   rN   rC   rK   rP   rL   rQ   )rZ   r   r   r4   rK   r5   r5   r6   r[     s   
zWebSocketClientFactory.__init__Nr   r5   r5   r5   r6   r&     r   r&   c                   @   sX   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Zdd Z	dd Z
dd Zdd ZdS )r'   a  
    An adapter for stream-based transport over WebSocket.

    This follows `websockify <https://github.com/kanaka/websockify>`_
    and should be compatible with that.

    It uses WebSocket subprotocol negotiation and supports the
    following WebSocket subprotocols:

      - ``binary`` (or a compatible subprotocol)
      - ``base64``

    Octets are either transmitted as the payload of WebSocket binary
    messages when using the ``binary`` subprotocol (or an alternative
    binary compatible subprotocol), or encoded with Base64 and then
    transmitted as the payload of WebSocket text messages when using
    the ``base64`` subprotocol.
    c                 C   s   t |tr'|}|jD ]}|| jjv r|dk| _|  S q
ttjd| jjt |t	rJ|}|j
| jjvrB| t
jjd| jj |j
dk| _d S td)Nbase64z2this server only speaks {0} WebSocket subprotocolsz2this client only speaks {0} WebSocket subprotocolszlogic error)r7   r   r@   rT   _subprotocols_binaryModer   NOT_ACCEPTABLEr:   r   r   _fail_connectionWebSocketProtocol CLOSE_STATUS_CODE_PROTOCOL_ERROR	Exception)rZ   requestOrResponserequestpr   r5   r5   r6   r   $  s   



z"WrappingWebSocketAdapter.onConnectc                 C   s   | j   d S rX   )_protor   r   r5   r5   r6   r   6  ra   zWrappingWebSocketAdapter.onOpenc              
   C   sz   || j kr| tjjd d S |s5zt|}W n ty4 } z| tjjd| W Y d }~nd }~ww | j	
| d S )Nz>message payload type does not match the negotiated subprotocolz*message payload base64 decoding error: {0})r   r   r   r   "CLOSE_STATUS_CODE_UNSUPPORTED_DATAr   r   !CLOSE_STATUS_CODE_INVALID_PAYLOADr:   r   r   )rZ   r   r   er5   r5   r6   r   9  s   
"z"WrappingWebSocketAdapter.onMessagec                 C   s   | j d  d S rX   )r   r   r   r5   r5   r6   r   E  r   z WrappingWebSocketAdapter.onClosec                 C   sB   t |tksJ | jr| j|dd d S t|}| j|dd d S )NT)r   F)r;   r   r   sendMessager   r   r5   r5   r6   writeH  s
   zWrappingWebSocketAdapter.writec                 C   s   |D ]}|  | qd S rX   )r   )rZ   r   dr5   r5   r6   writeSequenceQ  s   z&WrappingWebSocketAdapter.writeSequencec                 C   r   rX   )	sendCloser   r5   r5   r6   r   V  s   z'WrappingWebSocketAdapter.loseConnectionc                 C   
   | j  S rX   )rv   getPeerr   r5   r5   r6   r   Z     
z WrappingWebSocketAdapter.getPeerc                 C   r   rX   )rv   getHostr   r5   r5   r6   r   ^  r   z WrappingWebSocketAdapter.getHostN)rn   ro   rp   rq   r   r   r   r   r   r   r   r   r   r5   r5   r5   r6   r'     s    	r'   c                   @   r   )r(   zD
    Server protocol for stream-based transport over WebSocket.
    Nr   r5   r5   r5   r6   r(   c  r   r(   c                   @   r   )r)   zD
    Client protocol for stream-based transport over WebSocket.
    Nr   r5   r5   r5   r6   r)   i  r   r)   c                   @   s:   e Zd ZdZ				dddZdd Zd	d
 Zdd ZdS )r*   zL
    Wrapping server factory for stream-based transport over WebSocket.
    NTr   c                 C   sl   || _ ddg| _|r| j| tj| ||| jd | j|d | jdd |r4dd }| j|d	 d
S d
S )z

        :param factory: Stream-based factory to be wrapped.
        :type factory: A subclass of ``twisted.internet.protocol.Factory``
        :param url: WebSocket URL of the server this server factory will work for.
        :type url: unicode
        binaryr   r\   r4   r@   autoFragmentSizeF
failByDropc                 S   s$   | D ]}t |trt|  S qd S rX   )r7   r   r   )offersofferr5   r5   r6   accept  s
   
z7WrappingWebSocketServerFactory.__init__.<locals>.acceptperMessageCompressionAcceptN)_factoryr   appendr%   r[   setProtocolOptions)rZ   rT   r\   r4   enableCompressionr   subprotocolr   r5   r5   r6   r[   t  s   
z'WrappingWebSocketServerFactory.__init__c                 C   &   t  }| |_| j||_||j_|S rX   )r(   rT   r   buildProtocolr   rv   rZ   addrrd   r5   r5   r6   r     
   z,WrappingWebSocketServerFactory.buildProtocolc                 C      | j   t|  d S rX   )r   startFactoryr%   r   r5   r5   r6   r        
z+WrappingWebSocketServerFactory.startFactoryc                 C   r   rX   )r   stopFactoryr%   r   r5   r5   r6   r     r   z*WrappingWebSocketServerFactory.stopFactoryNTr   N)rn   ro   rp   rq   r[   r   r   r   r5   r5   r5   r6   r*   o  s    
*r*   c                   @   s*   e Zd ZdZ				d	ddZdd ZdS )
r+   zL
    Wrapping client factory for stream-based transport over WebSocket.
    NTr   c           	      C   s   || _ ddg| _|r| j| tj| ||| jd | j|d | jdd |r>t g}| j|d dd	 }| j|d
 dS dS )a  

        :param factory: Stream-based factory to be wrapped.
        :type factory: A subclass of ``twisted.internet.protocol.Factory``
        :param url: WebSocket URL of the server this client factory will connect to.
        :type url: unicode
        r   r   r   r   Fr   )perMessageCompressionOffersc                 S   s   t | tr	t| S d S rX   )r7   r   r   )r   r5   r5   r6   r     s   
z7WrappingWebSocketClientFactory.__init__.<locals>.acceptr   N)r   r   r   r&   r[   r   r   )	rZ   rT   r\   r4   r   r   r   r   r   r5   r5   r6   r[     s"   
z'WrappingWebSocketClientFactory.__init__c                 C   r   rX   )r)   rT   r   r   r   rv   r   r5   r5   r6   r     r   z,WrappingWebSocketClientFactory.buildProtocolr   )rn   ro   rp   rq   r[   r   r5   r5   r5   r6   r+     s    
-r+      c                 C   s   t | dr	| j}nddlm} | jr |du r ddlm} | }| jdur9|| _|| jd | jd | ||}|S | jrJ|	| j
| j| |||}|S || j
| j| ||}|S )a  
    Establish WebSocket connection to a server. The connection parameters like target
    host, port, resource and others are provided via the factory.

    :param factory: The WebSocket protocol factory to be used for creating client protocol instances.
    :type factory: An :class:`autobahn.websocket.WebSocketClientFactory` instance.

    :param contextFactory: SSL context factory, required for secure WebSocket connections ("wss").
    :type contextFactory: A `twisted.internet.ssl.ClientContextFactory <http://twistedmatrix.com/documents/current/api/twisted.internet.ssl.ClientContextFactory.html>`_ instance.

    :param timeout: Number of seconds to wait before assuming the connection has failed.
    :type timeout: int

    :param bindAddress: A (host, port) tuple of local address to bind to, or None.
    :type bindAddress: tuple

    :returns: The connector.
    :rtype: An object which implements `twisted.interface.IConnector <http://twistedmatrix.com/documents/current/api/twisted.internet.interfaces.IConnector.html>`_.
    r4   r   r3   NrJ   rL   rM   )r   r4   rO   rN   rK   ClientContextFactoryrC   rQ   
connectTCP
connectSSLrL   rM   )rT   rQ   timeoutbindAddressr4   rK   connr5   r5   r6   r-     s    

r-   2    c                 C   sb   t | dr	| j}nddlm} | jr&|du rtd|| j| |||}|S || j| ||}|S )a  
    Listen for incoming WebSocket connections from clients. The connection parameters like
    listening port and others are provided via the factory.

    :param factory: The WebSocket protocol factory to be used for creating server protocol instances.
    :type factory: An :class:`autobahn.websocket.WebSocketServerFactory` instance.

    :param contextFactory: SSL context factory, required for secure WebSocket connections ("wss").
    :type contextFactory: A twisted.internet.ssl.ContextFactory.

    :param backlog: Size of the listen queue.
    :type backlog: int

    :param interface: The interface (derived from hostname given) to bind to, defaults to '' (all).
    :type interface: str

    :returns: The listening port.
    :rtype: An object that implements `twisted.interface.IListeningPort <http://twistedmatrix.com/documents/current/api/twisted.internet.interfaces.IListeningPort.html>`_.
    r4   r   r3   NzCSecure WebSocket listen requested, but no SSL context factory given)r   r4   rO   rN   r   	listenSSLrM   	listenTCP)rT   rQ   backlog	interfacer4   listenerr5   r5   r6   r,     s   
r,   c                   @   r   )r.   z
    Twisted-based WAMP-over-WebSocket server protocol.

    Implements:

    * :class:`autobahn.wamp.interfaces.ITransport`
    Nr   r5   r5   r5   r6   r.   8      r.   c                   @      e Zd ZdZeZdd ZdS )r/   zD
    Twisted-based WAMP-over-WebSocket server protocol factory.
    c                 O   sB   | dd}tj| || | j|d< tj| g|R i | dS )a  

        :param factory: A callable that produces instances that implement
            :class:`autobahn.wamp.interfaces.ITransportHandler`
        :type factory: callable

        :param serializers: A list of WAMP serializers to use (or ``None``
            for all available serializers).
        :type serializers: list of objects implementing
            :class:`autobahn.wamp.interfaces.ISerializer`
        serializersNr@   )r   r   r/   r[   
_protocolsr%   rZ   rT   r   r   r  r5   r5   r6   r[   K  s   
z#WampWebSocketServerFactory.__init__N)rn   ro   rp   rq   r.   r   r[   r5   r5   r5   r6   r/   C      r/   c                   @   r   )r0   z
    Twisted-based WAMP-over-WebSocket client protocol.

    Implements:

    * :class:`autobahn.wamp.interfaces.ITransport`
    Nr   r5   r5   r5   r6   r0   b  r  r0   c                   @   r  )r1   zD
    Twisted-based WAMP-over-WebSocket client protocol factory.
    c                 O   sH   | dd}tj| || | j|d< tj| g|R i | d| _dS )a  

        :param factory: A callable that produces instances that implement
            :class:`autobahn.wamp.interfaces.ITransportHandler`
        :type factory: callable

        :param serializer: The WAMP serializer to use (or ``None`` for
           "best" serializer, chosen as the first serializer available from
           this list: CBOR, MessagePack, UBJSON, JSON).
        :type serializer: object implementing :class:`autobahn.wamp.interfaces.ISerializer`
        r  Nr@   F)r   r   r1   r[   r  r&   noisyr  r5   r5   r6   r[   u  s
   

z#WampWebSocketClientFactory.__init__N)rn   ro   rp   rq   r0   r   r[   r5   r5   r5   r6   r1   m  r  r1   )Nr  N)Nr  r	  )Nr   r   r   typingr   zope.interfacer   r   use_twistedtwisted.internet.protocoltwistedrO   r   twisted.internet.interfacesr   twisted.internet.errorr   r	   r
   twisted.internet.deferr   twisted.python.failurer   r   autobahn.utilr   r   r   r   r   autobahn.wampr   autobahn.wamp.typesr   autobahn.websocket.typesr   r   r   autobahn.websocketr   autobahn.websocket.interfacesr   autobahn.twisted.utilr   r   autobahn.websocket.compressr   r   r   r   __all__r    r>   rI   rW   r2   internetProtocolr!   r"   r#   objectr$   r%   ServerFactoryr&   ClientFactoryr'   r(   r)   r*   r+   r-   r,   r.   r/   r0   r1   r5   r5   r5   r6   <module>   sp   )7 7)S?:+#

