
                         r   S r SSKrSSKrSSKrSSKrSSKrSSK7  SSK7  SSK7  \R                  \R                  S4/r\" \S5      (       a(  \R                  \R                  \R                  S45        \" \S5      (       a(  \R                  \R                  \R                   S45        \" \S5      (       a(  \R                  \R                  \R"                  S	45        \" \S
5      (       a(  \R                  \R                  \R$                  S45        Sq/ SQr " S S\5      rS rS rS rS rS rg)aK  
websocket - WebSocket client library for Python

Copyright (C) 2010 Hiroki Ohtani(liris)

    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 Street, Fifth Floor,
    Boston, MA 02110-1335  USA

    N   )*SO_KEEPALIVETCP_KEEPIDLE   TCP_KEEPINTVL
   TCP_KEEPCNT   )DEFAULT_SOCKET_OPTIONsock_optsetdefaulttimeoutgetdefaulttimeoutrecv	recv_linesendc                       \ rS rSrS rSrg)r   1   c                 >    Uc  / nUc  0 nXl         X l        S U l        g )Nsockoptsslopttimeout)selfr   r   s      $lib/third_party/websocket/_socket.py__init__sock_opt.__init__3   s'    ?G>F    r   N)__name__
__module____qualname____firstlineno__r   __static_attributes__ r   r   r   r   1   s    r   r   c                     U q g)zi
Set the global timeout setting to connect.

timeout: default socket timeout time. This value is second.
N_default_timeout)r   s    r   r   r   =   s
     r   c                      [         $ )z7
Return the global timeout setting(second) to connect.
r&   r$   r   r   r   r   G   s
     r   c                   ^ ^ T (       d  [        S5      eUU 4S jn T R                  5       S:X  a  T R                  T5      nOU" 5       n U(       d  [        S5      eU$ ! [        R                   a  n[        U5      n[        U5      eS nAf[         a7  n[        U5      n[        U[        5      (       a  SU;   a  [        U5      ee S nAff = f)Nsocket is already closed.c                    >  TR                  T5      $ ! [         a"  n U R                  S   [        :w  a  e  S n A O\S n A f[        R
                   aB  n[        U5      nUc  e U[        R                  :w  d  U[        R                  :w  a  e  S nAOS nAff = f[        R                  " T4SSTR                  5       5      u  p4n U(       a  TR                  T5      $ g Nr   r$   )r   SSLErrorargsSSL_ERROR_WANT_READsocketerrorextract_error_codeerrnoEAGAINEWOULDBLOCKselect
gettimeout)eexc
error_coderwbufsizesocks        r   _recvrecv.<locals>._recvR   s    	99W%% 	vvay// 0|| 	+C0J!U\\)Z5;L;L-L .M		 --"b$//2CDa99W%%     
B;B8BBr   	timed outzConnection is already closed.)
"WebSocketConnectionClosedExceptionr7   r   r0   r   extract_err_messageWebSocketTimeoutExceptionr-   
isinstancestr)r>   r=   r?   bytes_r8   messages   ``    r   r   r   N   s    01LMM&$??!YYw'FWF 0+- 	- M >> 1%a('00 %a(gs##w(>+G44s)   %A A C3B		C2CCc                     / n [        U S5      nUR                  U5        U[        R                  " S5      :X  a  OM:  [        R                  " S5      R	                  U5      $ )Nr   
 )r   appendsixbjoin)r>   linecs      r   r   r   z   sQ    D
qMAd	 
 559>>$r   c                   ^ ^ [        T[        R                  5      (       a  TR                  S5      mT (       d  [	        S5      eUU 4S jn T R                  5       S:X  a  T R                  T5      $ U" 5       $ ! [        R                   a  n[        U5      n[        U5      eS nAf[         a7  n[        U5      n[        U[        5      (       a  SU;   a  [        U5      ee S nAff = f)Nzutf-8r*   c                    >  TR                  T5      $ ! [         a"  n U R                  S   [        :w  a  e  S n A O\S n A f[        R
                   aB  n[        U5      nUc  e U[        R                  :w  d  U[        R                  :w  a  e  S nAOS nAff = f[        R                  " ST4STR                  5       5      u  p4n U(       a  TR                  T5      $ g r,   )r   r-   r.   SSL_ERROR_WANT_WRITEr0   r1   r2   r3   r4   r5   r6   r7   )r8   r9   r:   r;   r<   datar>   s        r   _sendsend.<locals>._send   s    	99T?" 	vvay00 1|| 	+C0J!U\\)Z5;L;L-L .M		 --THb$//2CDa99T?" rA   r   rB   )rF   rN   	text_typeencoderC   r7   r   r0   r   rD   rE   	ExceptionrG   )r>   rV   rW   r8   rI   s   ``   r   r   r      s    $&&{{7#01LMM#$??!99T?"7N>> 1%a('00 %a(gs##w(>+G44s*   $A9 2A9 9C'B##C'02C""C')__doc__r3   r6   r0   rN   sys_exceptions_ssl_compat_utilsSOL_TCPTCP_NODELAYr   hasattrrM   
SOL_SOCKETr   r   r   r
   r'   __all__objectr   r   r   r   r   r   r$   r   r   <module>rg      s#  *    
 
    ..&*<*<a@A 
6>""  &"3"3V5H5H!!LM
6>""  &..&2E2Er!JK
6?##  &..&2F2F!KL
6=!!  &..&2D2Da!HI (	v 	)X &r   