3 g÷ÔY&ã@sdZddlZddlZddlTddlTddlTejejdfgZe edƒrZej ej ej dfƒe edƒrxej ejej dfƒe edƒr–ej ejejd fƒe ed ƒr´ej ejejd fƒdad d dddddgZGdd „d eƒZdd„Zdd„Zdd„Zdd„Zdd„ZdS)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@seZdZdd„ZdS)r cCs.|dkr g}|dkri}||_||_d|_dS)N)ÚsockoptÚssloptÚtimeout)Úselfrr©rúB/Users/olari/OneDrive/sandbox/awsBlog2/lambda/websocket/_socket.pyÚ__init__0szsock_opt.__init__N)Ú__name__Ú __module__Ú __qualname__rrrrrr .scCs|adS)zu Set the global timeout setting to connect. timeout: default socket timeout time. This value is second. N)Ú_default_timeout)rrrrr :scCstS)z? Return the global timeout setting(second) to connect. )rrrrrrDscCsœ|s tdƒ‚y|j|ƒ}Wnptjk rN}zt|ƒ}t|ƒ‚WYdd}~Xn>tk rŠ}z"t|ƒ}|dkrxt|ƒ‚n‚WYdd}~XnX|s˜tdƒ‚|S)Nzsocket is already closed.zThe read operation timed outzConnection is already closed.)Ú"WebSocketConnectionClosedExceptionrÚsocketrÚextract_err_messageÚWebSocketTimeoutExceptionÚSSLError)ÚsockÚbufsizeÚbytes_ÚeÚmessagerrrrKs  cCs>g}x(t|dƒ}|j|ƒ|tjdƒkrPqWtjdƒj|ƒS)NrÚ Ú)rÚappendÚsixÚbÚjoin)r"ÚlineÚcrrrrbs  cCs¬t|tjƒr|jdƒ}|s"tdƒ‚y |j|ƒStjk r`}zt|ƒ}t |ƒ‚WYdd}~XnHt k r¦}z,t|ƒ}t|t ƒr”d|kr”t |ƒ‚n‚WYdd}~XnXdS)Nzutf-8zsocket is already closed.z timed out) Ú isinstancer*Ú text_typeÚencoderrrrrr Ú ExceptionÚstr)r"Údatar%r&rrrrls    )Ú__doc__rr*Ú _exceptionsÚ _ssl_compatÚ_utilsÚSOL_TCPÚ TCP_NODELAYr Úhasattrr)Ú SOL_SOCKETrrrr rÚ__all__Úobjectr r rrrrrrrrÚs.