From 90caf7544cbe49b7c02c909908811e0571e8736f Mon Sep 17 00:00:00 2001 From: sylvain Date: Sun, 13 Oct 2013 14:04:48 +0200 Subject: [PATCH] add comments --- rdpy/protocols/common/layer.py | 2 +- rdpy/protocols/common/protocolbuffer.py | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/rdpy/protocols/common/layer.py b/rdpy/protocols/common/layer.py index baf9960..a6a09ca 100644 --- a/rdpy/protocols/common/layer.py +++ b/rdpy/protocols/common/layer.py @@ -1,5 +1,5 @@ ''' -@author: citronneur +@author: sylvain ''' class Layer(object): ''' diff --git a/rdpy/protocols/common/protocolbuffer.py b/rdpy/protocols/common/protocolbuffer.py index f51c5f0..6d27946 100644 --- a/rdpy/protocols/common/protocolbuffer.py +++ b/rdpy/protocols/common/protocolbuffer.py @@ -6,7 +6,10 @@ from stream import Stream class ProtocolBuffer(protocol.Protocol): ''' - classdocs + Inherit from protocol twisted class + allow this protocol to wait until expected size of packet + throw expect function and set a callback or by default + call recv function (may be override) ''' def __init__(self): ''' @@ -23,10 +26,15 @@ class ProtocolBuffer(protocol.Protocol): inherit from protocol class main event of received data ''' + #add in buffer self._buffer += data + #while buffer have expected size call local callback while len(self._buffer) >= self._expectedLen: + #expected data is first expected bytes expectedData = Stream(self._buffer[0:self._expectedLen]) + #rest is for next event of automata self._buffer = self._buffer[self._expectedLen:] + #call recv function self.recv(expectedData) def expect(self, expectedLen, callback = None):