
    8'hu                        d dl mZ d dlmZmZ d dlZd dlmZ d dlZ ej                          d dl
Zd dlmZ d dlmZ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 d dlmZ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+m,Z,m-Z- dZ.d Z/d Z0d Z1d Z2 G d de%      Z3 G d dejh                  jF                  jj                        Z6e G d de6e#jn                               Z7e G d de6e#jp                               Z8 G d de9      Z:e G d  d!e:e#jv                  ejh                  jF                  jx                               Z;e G d" d#e:e#jz                  ejh                  jF                  j|                               Z= ee       G d$ d%e9             Z? G d& d'e?e7      Z@ G d( d)e?e8      ZA G d* d+e;      ZB G d, d-e=      ZCed8d.       ZDed9d/       ZEe G d0 d1ej                  e7             ZFe G d2 d3ej                  e;             ZGe G d4 d5ej                  e8             ZHe G d6 d7ej                  e=             ZIy):    )absolute_import)	b64encode	b64decodeN)implementer)	endpoints)
ITransportISSLTransport)ConnectionDoneConnectionAbortedConnectionLost)Deferred)public)_is_tls_error_maybe_tls_reason)	websocket)ConnectionRequestConnectionResponseConnectionDenyTransportDetails)protocol)IWebSocketClientAgent)peer2str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                     t        |       S )zB
    :returns: an instance implementing IWebSocketClientAgent
    )_TwistedWebSocketClientAgentreactors    V/var/www/html/trade_iq/venv/lib/python3.12/site-packages/autobahn/twisted/websocket.pyr   r   V   s     (00    c                     t        | t        j                        s#t        dj	                  t        |                   | j                  d      s| j                  d      st        d      y)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six	text_type
ValueErrorformattype
startswith)transport_configs    r4   check_transport_configr?   ]   sg    
 &6;BB4HXCYZ
 	
 &&w/&&x0D
 	
 r5   c                     t        | t              st        d      g d}| j                         D ]   }||vst        dj	                  |             y)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   dictr:   keysr;   )options
valid_keysactual_ks      r4   check_client_optionsrK   q   s_    
 gt$&
 	

J LLN :%077A r5   c                    |j                   r!ddlm} |j                  |j                        }|j
                  :|_        t        j                  | |j
                  d   |j
                  d         }|S |j                   r4ddlm} t        j                  | |j                  |j                        }|S t        j                  | |j                  |j                        }|S )Nr   sslhostport)isSecuretwisted.internetrN   optionsForClientTLSrO   rE   contextFactoryr   HostnameEndpointSSL4ClientEndpointrP   )r3   factoryr>   rH   rN   context_factoryendpoints          r4   _endpoint_from_configrZ      s     (11',,?}} !0--MM'"MM'"
0 O# , 33	H O !11H Or5   c                       e Zd ZdZd ZddZy)r1   z6
    This agent creates connections using Twisted
    c                     || _         y N)_reactor)selfr3   s     r4   __init__z%_TwistedWebSocketClientAgent.__init__   s	    r5   Nc                 $  	 t        |       t        |       t        d|| j                  d|}|t        n||_        t        | j                  |||      }t               	|j                  |      }	fd	fd}|j                  |       	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).
        )urlr3   c                 (    j                  |        y r]   )errback)frtn_ds    r4   failedz1_TwistedWebSocketClientAgent.open.<locals>.failed   s    MM!r5   c                 N      fd} j                   j                  |        S )Nc                 *    j                         | S r]   )callback)argprotorf   s    r4   handshake_completedzQ_TwistedWebSocketClientAgent.open.<locals>.got_proto.<locals>.handshake_completed   s    u%
r5   )is_openaddCallbacks)rl   rm   rg   rf   s   ` r4   	got_protoz4_TwistedWebSocketClientAgent.open.<locals>.got_proto   s$     MM&&':FCLr5    )
r?   rK   r$   r^   r!   r   rZ   r   connectro   )
r_   r>   rH   protocol_classrW   rY   proto_drp   rg   rf   s
           @@r4   openz!_TwistedWebSocketClientAgent.open   s    " 	/0W%( 
 MM
 

 7E6L2R` )AQSZ[
""7+		 	Y/r5   r]   )__name__
__module____qualname____doc__r`   ru   rq   r5   r4   r1   r1      s     ,r5   r1   c                       e Zd ZdZdZ ej                         Zd Zd Z	d Z
ddZd Zd Zd	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zd Zy)r   zJ
    Adapter class for Twisted WebSocket client and server protocols.
    z<never connected>c                    	 t        | j                  j                               | _        | j                          | j                  j                  d| j                         	 | j                  j                  | j                         y # t        $ r- dj                  | j                  j                        | _        Y w xY w#  Y y xY w)Nz
process:{}zConnection made to {peer}peer)r   	transportgetPeerr}   AttributeErrorr;   pid_connectionMadelogdebugsetTcpNoDelay
tcpNoDelayr_   s    r4   connectionMadez'WebSocketAdapterProtocol.connectionMade   s    	A !7!7!9:DI
 	2C	NN((9  	A%,,T^^-?-?@DI	A	s   (B "%C 3B>=B>Cc                 N   t        |j                  t              r)| j                  j	                  d| j
                         nQt        |j                        r0| j                  j                  t        |j                               nt        |j                  t              r(| j                  j	                  d| j
                         nt        |j                  t              rjt        |j                        }t        |j                  d      r|j                  j                  }| j                  j	                  d| j
                  |       nF| j                  j	                  d| j
                  t        |j                        |j                         | j                  |       y )	Nz,Connection to/from {peer} was closed cleanlyr|   z-Connection to/from {peer} was aborted locallymessagezDConnection to/from {peer} was lost in a non-clean fashion: {message})r}   r   z7Connection to/from {peer} lost ({error_type}): {error}))r}   
error_typeerror)r7   valuer
   r   r   r}   r   r   r   r   r   strhasattrr   r<   _connectionLost)r_   reasonr   s      r4   connectionLostz'WebSocketAdapterProtocol.connectionLost  s(   fllN3HHNNI $		  + 6<<(HHNN,V\\:;&78HHNNJ $		  + n5&,,'Gv||Y/ ,,..HHNNVYY   HHNNT $		d6<<6HPVP\P\  ^ 	V$r5   c                 &    | j                  |       y r]   )_dataReceivedr_   datas     r4   dataReceivedz%WebSocketAdapterProtocol.dataReceived"  s    4 r5   c                     |r1t        | j                  d      r| j                  j                          y | j                  j                          y )NabortConnection)r   r~   r   loseConnection)r_   aborts     r4   _closeConnectionz)WebSocketAdapterProtocol._closeConnection%  s5    WT^^->?NN**, NN))+r5   c                 $    | j                          y r]   )onOpenr   s    r4   _onOpenz WebSocketAdapterProtocol._onOpen,  s    r5   c                 &    | j                  |       y r]   )onMessageBegin)r_   isBinarys     r4   _onMessageBeginz(WebSocketAdapterProtocol._onMessageBegin/  s    H%r5   c                 &    | j                  |       y r]   )onMessageFrameBegin)r_   lengths     r4   _onMessageFrameBeginz-WebSocketAdapterProtocol._onMessageFrameBegin2  s      (r5   c                 &    | j                  |       y r]   )onMessageFrameDatar_   payloads     r4   _onMessageFrameDataz,WebSocketAdapterProtocol._onMessageFrameData5  s    (r5   c                 $    | j                          y r]   )onMessageFrameEndr   s    r4   _onMessageFrameEndz+WebSocketAdapterProtocol._onMessageFrameEnd8  s     r5   c                 &    | j                  |       y r]   )onMessageFramer   s     r4   _onMessageFramez(WebSocketAdapterProtocol._onMessageFrame;  s    G$r5   c                 $    | j                          y r]   )onMessageEndr   s    r4   _onMessageEndz&WebSocketAdapterProtocol._onMessageEnd>  s    r5   c                 (    | j                  ||       y r]   )	onMessage)r_   r   r   s      r4   
_onMessagez#WebSocketAdapterProtocol._onMessageA  s    w)r5   c                 &    | j                  |       y r]   )onPingr   s     r4   _onPingz WebSocketAdapterProtocol._onPingD      Gr5   c                 &    | j                  |       y r]   )onPongr   s     r4   _onPongz WebSocketAdapterProtocol._onPongG  r   r5   c                 *    | j                  |||       y r]   )onCloser_   wasCleancoder   s       r4   _onClosez!WebSocketAdapterProtocol._onCloseJ  s    XtV,r5   c                 <    | j                   j                  ||       y)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)r~   registerProducer)r_   producer	streamings      r4   r   z)WebSocketAdapterProtocol.registerProducerM  s     	'')<r5   c                 8    | j                   j                          y)zA
        Unregister Twisted producer with this protocol.
        N)r~   unregisterProducerr   s    r4   r   z+WebSocketAdapterProtocol.unregisterProducerX  s     	))+r5   N)F)rv   rw   rx   ry   r}   txaiomake_loggerr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rq   r5   r4   r   r      ss      D
%


C$%:!,&))!%*-	=,r5   r   c                   :    e Zd ZdZ ej
                         ZddZy)r    z
    Base class for Twisted-based WebSocket server protocols.

    Implements :class:`autobahn.websocket.interfaces.IWebSocketChannel`.
    c                 0    t        | j                  d|      S )W
        Implements :func:`autobahn.wamp.interfaces.ITransport.get_channel_id`
        Tr   r~   r_   channel_id_types     r4   get_channel_idz&WebSocketServerProtocol.get_channel_idi  s     $DNND/JJr5   N
tls-unique)rv   rw   rx   ry   r   r   r   r   rq   r5   r4   r    r    _  s     %


CKr5   r    c                   L    e Zd ZdZ ej
                         Zd Zd ZddZ	d Z
y)r!   z
    Base class for Twisted-based WebSocket client protocols.

    Implements :class:`autobahn.websocket.interfaces.IWebSocketChannel`.
    c                 &    | j                  |       y r]   )	onConnect)r_   responses     r4   
_onConnectz"WebSocketClientProtocol._onConnectz  s    x r5   c                     | j                   j                  d       | j                  j                  | j                  j
                         y )NzStarting TLS upgrade)r   r   r~   startTLSrW   rT   r   s    r4   r   z WebSocketClientProtocol.startTLS}  s/    -. ; ;<r5   c                 0    t        | j                  d|      S )r   Fr   r   s     r4   r   z&WebSocketClientProtocol.get_channel_id  s     $DNNE?KKr5   c                     t        j                  | j                        }|rdt        | j                  dd      i}ni }t	        | j
                  ||      S )z]
        Internal helper.
        Base class calls this to create a TransportDetails
        r   F)r}   	is_securesecure_channel_id)r	   
providedByr~   r   r   r}   )r_   r   r   s      r4   _create_transport_detailsz1WebSocketClientProtocol._create_transport_details  sR     ",,T^^<	3DNNE=Y! !#TYY)Whiir5   Nr   )rv   rw   rx   ry   r   r   r   r   r   r   r   rq   r5   r4   r!   r!   p  s/     %


C!=Ljr5   r!   c                       e Zd ZdZy)r"   zP
    Adapter class for Twisted-based WebSocket client and server factories.
    Nrv   rw   rx   ry   rq   r5   r4   r"   r"         r5   r"   c                       e Zd ZdZd Zy)r#   z
    Base class for Twisted-based WebSocket server factories.

    Implements :class:`autobahn.websocket.interfaces.IWebSocketServerChannelFactory`
    c                     |j                  dd      }|ddlm} || _        t        j                  j
                  | g|i | y)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.
        r3   Nr   r2   )poprR   r3   r   r#   r`   )r_   argskwargsr3   s       r4   r`   zWebSocketServerFactory.__init__  sA     **Y-?0''00GGGr5   Nrv   rw   rx   ry   r`   rq   r5   r4   r#   r#     s    Hr5   r#   c                       e Zd ZdZd Zy)r$   z
    Base class for Twisted-based WebSocket client factories.

    Implements :class:`autobahn.websocket.interfaces.IWebSocketClientChannelFactory`
    c                    |j                  dd      }|ddlm} || _        t        j                  j
                  | g|i | | j                  r4| j                  'ddlm} |j                  | j                        | _        yyy)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.
        r3   Nr   r2   rM   )r   rR   r3   r   r$   r`   rQ   rE   rN   rS   rO   rT   )r_   r   r   r3   rN   s        r4   r`   zWebSocketClientFactory.__init__  sv     **Y-?0''00GGG ==TZZ3 -"%"9"9$))"DD 4=r5   Nr   rq   r5   r4   r$   r$     s    Er5   r$   c                   F    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 Zy)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                 P   t        |t              rv|}|j                  D ](  }|| j                  j                  v s|dk7  | _        |c S  t        t        j                  dj                  | j                  j                              t        |t              r|}|j                  | j                  j                  vrM| j                  t        j                  j                  dj                  | j                  j                               |j                  dk7  | _        y t        d      )Nbase64z2this server only speaks {0} WebSocket subprotocolsz2this client only speaks {0} WebSocket subprotocolszlogic error)r7   r   rB   rW   _subprotocols_binaryModer   NOT_ACCEPTABLEr;   r   r   _fail_connectionWebSocketProtocol CLOSE_STATUS_CODE_PROTOCOL_ERROR	Exception)r_   requestOrResponserequestpr   s        r4   r   z"WrappingWebSocketAdapter.onConnect  s<   '):;'G&& 222()YD$H !!>!>@u@|@|  ~B  ~J  ~J  ~X  ~X  AY  Z  Z)+=>(H  (B(BB%%h&@&@&a&a  dY  d`  d`  ae  am  am  a{  a{  d|  } ( 1 1Y >D M**r5   c                 8    | j                   j                          y r]   )_protor   r   s    r4   r   zWrappingWebSocketAdapter.onOpen  s    ""$r5   c                 h   || j                   k7  r+| j                  t        j                  j                  d       y |s	 t        |      }| j                  j                  |       y # t        $ rC}| j                  t        j                  j                  dj                  |             Y d }~cd }~ww xY w)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   )r_   r   r   es       r4   r   z"WrappingWebSocketAdapter.onMessage  s    t'''!!("<"<"_"_  bc  da'0G KK$$W- ! a))(*D*D*f*f  iV  i]  i]  ^_  i`  a  aas   A% %	B1.9B,,B1c                 :    | j                   j                  d        y r]   )r   r   r   s       r4   r   z WrappingWebSocketAdapter.onClose  s    ""4(r5   c                     t        |      t        k(  sJ | j                  r| j                  |d       y t	        |      }| j                  |d       y )NT)r   F)r<   bytesr   sendMessager   r   s     r4   writezWrappingWebSocketAdapter.write  sL    DzU"#"TD1T?DTE2r5   c                 4    |D ]  }| j                  |        y r]   )r  )r_   r   ds      r4   writeSequencez&WrappingWebSocketAdapter.writeSequence&  s     	AJJqM	r5   c                 $    | j                          y r]   )	sendCloser   s    r4   r   z'WrappingWebSocketAdapter.loseConnection+  s    r5   c                 6    | j                   j                         S r]   )r~   r   r   s    r4   r   z WrappingWebSocketAdapter.getPeer/      ~~%%''r5   c                 6    | j                   j                         S r]   )r~   getHostr   s    r4   r  z WrappingWebSocketAdapter.getHost3  r  r5   N)rv   rw   rx   ry   r   r   r   r   r  r	  r   r   r  rq   r5   r4   r%   r%     s4    &+$%	.)3
((r5   r%   c                       e Zd ZdZy)r&   zD
    Server protocol for stream-based transport over WebSocket.
    Nr   rq   r5   r4   r&   r&   8  r   r5   r&   c                       e Zd ZdZy)r'   zD
    Client protocol for stream-based transport over WebSocket.
    Nr   rq   r5   r4   r'   r'   >  r   r5   r'   c                   2    e Zd ZdZ	 	 	 	 ddZd Zd Zd Zy)r(   zL
    Wrapping server factory for stream-based transport over WebSocket.
    Nc                    || _         ddg| _        |r| j                  j                  |       t        j	                  | ||| j                         | j                  |       | j                  d       |rd }| j                  |       y	y	)
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   rb   r3   rB   autoFragmentSizeF
failByDropc                 L    | D ]  }t        |t              st        |      c S  y r]   )r7   r   r   )offersoffers     r4   acceptz7WrappingWebSocketServerFactory.__init__.<locals>.acceptl  s)    # CE!%)?@;EBBCr5   perMessageCompressionAcceptN)_factoryr   appendr#   r`   setProtocolOptions)r_   rW   rb   r3   enableCompressionr  subprotocolr  s           r4   r`   z'WrappingWebSocketServerFactory.__init__I  s      '3%%k2'',/07262D2D 	( 	F 	1AB 	51C
 ###G r5   c                     t               }| |_        | j                  j                  |      |_        ||j                  _        |S r]   )r&   rW   r   buildProtocolr   r~   r_   addrrl   s      r4   r&  z,WrappingWebSocketServerFactory.buildProtocols  8    /1}}2248!&r5   c                 b    | j                   j                          t        j                  |        y r]   )r   startFactoryr#   r   s    r4   r+  z+WrappingWebSocketServerFactory.startFactoryz  s     ""$++D1r5   c                 b    | j                   j                          t        j                  |        y r]   )r   stopFactoryr#   r   s    r4   r-  z*WrappingWebSocketServerFactory.stopFactory~  s     !!#**40r5   NTr   N)rv   rw   rx   ry   r`   r&  r+  r-  rq   r5   r4   r(   r(   D  s+     #'"#!(HT21r5   r(   c                   &    e Zd ZdZ	 	 	 	 ddZd Zy)r)   zL
    Wrapping client factory for stream-based transport over WebSocket.
    Nc                 V   || _         ddg| _        |r| j                  j                  |       t        j	                  | ||| j                         | j                  |       | j                  d       |r3t               g}| j                  |       d }| j                  |	       y
y
)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                 :    t        | t              rt        |       S y r]   )r7   r   r   )r   s    r4   r  z7WrappingWebSocketClientFactory.__init__.<locals>.accept  s    h(AB:8DD Cr5   r  N)r   r   r!  r$   r`   r"  r   )	r_   rW   rb   r3   r#  r  r$  r  r  s	            r4   r`   z'WrappingWebSocketClientFactory.__init__  s      '3%%k2'',/07262D2D 	( 	F 	1AB 	51 -./F###GE ###G r5   c                     t               }| |_        | j                  j                  |      |_        ||j                  _        |S r]   )r'   rW   r   r&  r   r~   r'  s      r4   r&  z,WrappingWebSocketClientFactory.buildProtocol  r)  r5   r.  )rv   rw   rx   ry   r`   r&  rq   r5   r4   r)   r)     s!     #'"#!+HZr5   r)   c                    t        | d      r| j                  }nddlm} | j                  r|ddlm} |j                         }| j                  8|| _        |j                  | j                  d   | j                  d   | ||      }|S | j                  r,|j                  | j                  | j                  | |||      }|S |j                  | 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>`_.
    r3   r   r2   rM   rO   rP   )r   r3   rR   rQ   rN   ClientContextFactoryrE   rT   
connectTCP
connectSSLrO   rP   )rW   rT   timeoutbindAddressr3   rN   conns          r4   r+   r+     s    , w	"//,!, 557N}} !/!!'--"8'--:PRY[bdop K	 %%gllGLL'>[bdopD K %%gllGLL'7T_`DKr5   c                     t        | d      r| j                  }nddlm} | j                  r.|t	        d      |j                  | j                  | |||      }|S |j                  | 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>`_.
    r3   r   r2   zCSecure WebSocket listen requested, but no SSL context factory given)r   r3   rR   rQ   r   	listenSSLrP   	listenTCP)rW   rT   backlog	interfacer3   listeners         r4   r*   r*     sz    , w	"//,!abb$$W\\7NGU^_ O $$W\\7GYOOr5   c                       e Zd ZdZy)r,   z
    Twisted-based WAMP-over-WebSocket server protocol.

    Implements:

    * :class:`autobahn.wamp.interfaces.ITransport`
    Nr   rq   r5   r4   r,   r,         r5   r,   c                       e Zd ZdZeZd Zy)r-   zD
    Twisted-based WAMP-over-WebSocket server protocol factory.
    c                     |j                  dd      }t        j                  j                  | ||       | j                  |d<   t        j                  | g|i | y)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`
        serializersNrB   )r   r   r-   r`   
_protocolsr#   r_   rW   r   r   rE  s        r4   r`   z#WampWebSocketServerFactory.__init__   sT     jj5,,55dG[Q"oo{ 	''>t>v>r5   N)rv   rw   rx   ry   r,   r   r`   rq   r5   r4   r-   r-     s     +H?r5   r-   c                       e Zd ZdZy)r.   z
    Twisted-based WAMP-over-WebSocket client protocol.

    Implements:

    * :class:`autobahn.wamp.interfaces.ITransport`
    Nr   rq   r5   r4   r.   r.   7  rB  r5   r.   c                       e Zd ZdZeZd Zy)r/   zD
    Twisted-based WAMP-over-WebSocket client protocol factory.
    c                     |j                  dd      }t        j                  j                  | ||       | j                  |d<   t        j                  | g|i | y)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`
        rE  NrB   )r   r   r/   r`   rF  r$   rG  s        r4   r`   z#WampWebSocketClientFactory.__init__J  sR     jj5,,55dG[Q"oo{''>t>v>r5   N)rv   rw   rx   ry   r.   r   r`   rq   r5   r4   r/   r/   B  s     +H?r5   r/   )N   N)N2    )J
__future__r   r   r   r   r8   zope.interfacer   r   use_twistedtwisted.internet.protocoltwistedrR   r   twisted.internet.interfacesr   r	   twisted.internet.errorr
   r   r   twisted.internet.deferr   autobahn.utilr   r   r   autobahn.wampr   autobahn.websocket.typesr   r   r   r   autobahn.websocketr   autobahn.websocket.interfacesr   autobahn.twisted.utilr   r   autobahn.websocket.compressr   r   r   r   __all__r   r?   rK   rZ   r1   internetProtocolr   r    r!   objectr"   r#   ServerFactoryr$   ClientFactoryr%   r&   r'   r(   r)   r+   r*   r,   r-   r.   r/   rq   r5   r4   <module>rc     s  6 ' ' 
 &        & A  +   : #  ' ? @$ $41(2&R4#8 4nr,w//88AA r,j K68X8X K K  (j68X8X (j (jVf  H4h6U6UW^WgWgWpWpW~W~ H H2 E4h6U6UW^WgWgWpWpW~W~ E EN ZP(v P( P(f&>@W &>@W <1%; <1~7%; 7t ( (V    F )"G"GI`   ?!E!EG] ? ?< )"G"GI`   ?!E!EG] ? ?r5   