Exemplo n.º 1
0
func writeFrame(out io.Writer, f *frame) (int64, error) {
	var n int64 = 0
	if err := proto.WriteBinary(out, f.versionDir); err != nil {
		return n, err
	}
	n += 1

	if err := proto.WriteBinary(out, f.header); err != nil {
		return n, err
	}
	n += headerLen

	m, err := out.Write(f.body)
	return n + int64(m), err
}
Exemplo n.º 2
0
func ResultVoidResponse(request proto.Frame) proto.Frame {
	buf := new(bytes.Buffer)
	proto.WriteBinary(buf, ResultVoid)

	hdr := header{
		Opcode:   proto.OpResult,
		StreamID: request.StreamID(),
		Length:   uint32(buf.Len()),
	}

	return &frame{
		versionDir: proto.VersionDir(Version) | response,
		header:     hdr,
		body:       buf.Bytes(),
	}
}