î
&GäR‹	  ã               @   sñ   d  Z  d d l m Z m Z m Z d d l m Z m Z m Z e j	 Z	 e j
 Z
 e j Z e j Z e j Z d d l 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 d d	 l Td
 Z Gd d „  d e ƒ Z d S)a.   
Yoton is a Python package that provides a simple interface
to communicate between two or more processes. 

Yoton is ...
  * lightweight
  * written in pure Python
  * without dependencies (except Python)
  * available on Python version >= 2.4, including Python 3
  * cross-platform
  * pretty fast 

é    )ÚUIDÚstrÚbytes)ÚSignalÚTimerÚapp)ÚPackage)Ú
ConnectionÚConnectionCollection)ÚTcpConnection)ÚContext)ÚRequestServerÚ
do_request)Ú*z2.2c               @   s@   e  Z d  Z d Z d d d „ Z d d „  Z d d d	 „ Z d S)
ÚSimpleSocketaÕ   SimpleSocket()
    
    A simple socket has an API similar to a BSD socket. This socket
    sends whole text messages from one end to the other.
    
    This class subclasses the Yoton.Context class, which makes setting
    up this socket very easy.
    
    Example
    -------
    # One end
    s = SimpleSocket()
    s.bind('localhost:test')
    s.send("Hi")
    
    # Other end
    s = SimpleSocket()
    s.connect('localhost:test')
    print(s.recv())
    
    Fc             C   s8   t  j |  | ƒ t |  d ƒ |  _ t |  d ƒ |  _ d  S)NÚtext)r   Ú__init__Z
PubChannelÚ_csZ
SubChannelÚ_cr)ÚselfÚverbose© r   úI/Applications/pyzo2014a/lib/python3.4/site-packages/iep/yoton/__init__.pyr   F   s    zSimpleSocket.__init__c             C   s   |  j  j | ƒ d S)z� send(message)
        
        Send a text message. The message is queued and send
        over the socket by the IO-thread.
        
        N)r   Úsend)r   Úsr   r   r   r   M   s    zSimpleSocket.sendNc             C   s   |  j  j | ƒ S)zí recv(block=None):
        
        Read a text from the channel. What was send as one message is 
        always received as one message.
        
        If the channel is closed and all messages are read, returns ''.
        
        )r   Úrecv)r   Úblockr   r   r   r   V   s    	zSimpleSocket.recv)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r   /   s   	r   N)r    Z
yoton.miscr   r   r   Zyoton.eventsr   r   r   Z
call_laterZprocess_eventsZstart_event_loopZstop_event_loopZembed_event_loopZ
yoton.corer   Zyoton.connectionr	   r
   Zyoton.connection_tcpr   Zyoton.contextr   Zyoton.clientserverr   r   Zyoton.channelsÚ__version__r   r   r   r   r   Ú<module>   s   					
