def METHOD_NAME(self, data):
    # TODO: rewrite to avoid buffer copies.
    self._buffer += data
    while self._buffer:
        if self._curmsg_len == -1:
            if len(self._buffer) >= 8:
                self._curmsg_len = _uint64_unpacker(self._buffer[:8])[0]
                self._buffer = self._buffer[8:]
            else:
                return
        if self._curmsg_len > 0 and len(self._buffer) >= self._curmsg_len:
            msg = self._buffer[:self._curmsg_len]
            self._buffer = self._buffer[self._curmsg_len:]
            self._curmsg_len = -1
            yield msg
        else:
            return