def serialize(self): return Bytes.from_int(self._id, 8, False, False)
def deserialize_from(self, stream): self._id = Bytes(stream.read(8)).to_int(False, False)
def create(): sid = Bytes(os.urandom(8)) return SessionId(sid)
def deserialize_from(self, stream): self._curr = Bytes(stream.read(4)).to_int(False, False) self._content_related_sended = self._curr // 2
def serialize(self): return Bytes.from_int(self._curr, 4, False, False)
def _read_remote_chunk(self, chunk_size): data = Bytes(self.sock.recv(chunk_size)) self._in.write(data) return len(data)
def write(self, data): #self.sock.send( data ) self._out.write(data) print repr(Bytes(data))