ϪfFddlmZddlmZGddejZy))BytesIO)protocolc&eZdZdZdZdZdZdZy)StatefulProtocola-A Protocol that stores state for you. state is a pair (function, num_bytes). When num_bytes bytes of data arrives from the network, function is called. It is expected to return the next state or None to keep same state. Initial state is returned by getInitialState (override it). )NNrctjj|||jt df|_y)Nr)rProtocolmakeConnectiongetInitialStater _sful_data)self transports ct)N)NotImplementedError)r s rr z StatefulProtocol.getInitialStates!!rc|j\}}}|jdd|j||j}|j|||z |dk\rN|j |d}||dz }|d|}|j j ry|r|}||z |dk\rN|dk7rD|j }|jd|j|j|d}|||f|_y)Nr)r seekwritetellreadr disconnectingtruncate) r datastatebufferoffsetblendnextbs r dataReceivedzStatefulProtocol.dataReceiveds $vv Aq T{{} FVmuQx' E!H%A eAh F58A;D,,VmuQx' Q; A KKN OO  LLOF/rN)__name__ __module__ __qualname____doc__r r r r#rrrr sJ?"0rrN)iortwisted.internetrrrr(rrr+s%(0x(((0r