def send(self, message): ''' send stream on tcp layer format message into raw stream understood by transport layer @param message: (tuple | Type) ''' s = Stream() s.writeType(message) self.transport.write(s.getvalue())
def send(self, message): """ @summary: Send Stream on TCP layer write rdpy Stream message to str And send it to transport layer @param message: (tuple | Type) """ s = Stream() s.writeType(message) self.transport.write(s.getvalue())
def dataReceived(self, data): """ @summary: Inherit from twisted.protocol class main event of received data @param data: string data receive from twisted """ #add in buffer self._buffer += data #while buffer have expected size call local callback while self._expectedLen > 0 and 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)