def write_frame(self, buf):
        writer = Writer(buf)
        writer.write_octet(self.type())
        writer.write_short(self.channel_id)

        # Write a temporary value for the total length of the frame
        stream_args_len_pos = len(buf)
        writer.write_long(0)

        # Mark the point in the stream where we start writing arguments,
        # *including* the class and method ids.
        stream_method_pos = len(buf)

        writer.write_short(self.class_id)
        writer.write_short(self.method_id)

        # This is assuming that args is a Writer
        if self._args is not None:
            writer.write(self._args.buffer())

        # Write the total length back at the position we allocated
        stream_len = len(buf) - stream_method_pos
        writer.write_long_at(stream_len, stream_args_len_pos)

        # Write the footer
        writer.write_octet(0xce)
dataset/ETHPy150Open agoragames/haigha/haigha/frames/method_frame.py/MethodFrame.write_frame/original