U
    êO}Z;  ã                   @   s  d Z ddlZddlZddlZddlT ddlT ddlT ejejdfgZ	e
edƒrbe	 ejejdf¡ e
edƒr€e	 ejejdf¡ e
edƒrže	 ejejd	f¡ e
ed
ƒr¼e	 ejejdf¡ dadddddddgZG dd„ deƒZdd„ Zdd„ Zdd„ Zdd„ Zdd„ ZdS )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                   @   s   e Zd Zdd„ ZdS )r   c                 C   s.   |d krg }|d kri }|| _ || _d | _d S )N)ÚsockoptÚssloptÚtimeout)Úselfr   r   © r   ú3/usr/lib/python3/dist-packages/websocket/_socket.pyÚ__init__1   s    zsock_opt.__init__N)Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r   /   s   c                 C   s   | a dS )zu
    Set the global timeout setting to connect.

    timeout: default socket timeout time. This value is second.
    N©Ú_default_timeout)r   r   r   r   r   ;   s    c                   C   s   t S )z?
    Return the global timeout setting(second) to connect.
    r   r   r   r   r   r   E   s    c              
   C   s¦   | st dƒ‚z|  |¡}W nz tjk
rN } zt|ƒ}t|ƒ‚W 5 d }~X Y nH tk
r” } z*t|ƒ}t|tƒr‚d|kr‚t|ƒ‚n‚ W 5 d }~X Y nX |s¢t dƒ‚|S )Núsocket is already closed.ú	timed outzConnection is already closed.)	Ú"WebSocketConnectionClosedExceptionr   Úsocketr   Úextract_err_messageÚWebSocketTimeoutExceptionZSSLErrorÚ
isinstanceÚstr)ÚsockÚbufsizeZbytes_ÚeÚmessager   r   r   r   L   s"    
ÿc                 C   s:   g }t | dƒ}| |¡ |t d¡krq*qt d¡ |¡S )Nr   Ú
Ú )r   ÚappendÚsixÚbÚjoin)r&   ÚlineÚcr   r   r   r   c   s    

c              
   C   s®   t |tjƒr| d¡}| s"tdƒ‚z|  |¡W S  tjk
rb } zt|ƒ}t	|ƒ‚W 5 d }~X Y nH t
k
r¨ } z*t|ƒ}t |tƒr–d|kr–t	|ƒ‚n‚ W 5 d }~X Y nX d S )Nzutf-8r   r   )r$   r-   Z	text_typeÚencoder    r   r!   r   r"   r#   Ú	Exceptionr%   )r&   Údatar(   r)   r   r   r   r   m   s    

)Ú__doc__r!   r-   ÚsysÚ_exceptionsZ_ssl_compatZ_utilsZSOL_TCPZTCP_NODELAYr   Úhasattrr,   Z
SOL_SOCKETr   r   r   r	   r   Ú__all__Úobjectr   r   r   r   r   r   r   r   r   r   Ú<module>   s6   



  ÿ

