func WriteMessage(w io.Writer, msgID uint64, msg proto.Message) error {
	body, err := proto.Marshal(msg)
	if err != nil {
		return errors.Trace(err)
	}

	var header [msgHeaderSize]byte
	binary.BigEndian.PutUint16(header[0:2], msgMagic)
	binary.BigEndian.PutUint16(header[2:4], msgVersion)
	binary.BigEndian.PutUint32(header[4:8], uint32(len(body)))
	binary.BigEndian.PutUint64(header[8:16], msgID)

	if _, err = w.Write(header[:]); err != nil {
		return errors.Trace(err)
	}

	_, err = w.Write(body)
	return errors.Trace(err)
}
// WriteMessage writes a protocol buffer message to writer.
WriteMessage writes a protocol buffer message to writer.
// WriteMessage writes a protocol buffer message to writer .
func WriteMessage(w io.Writer, msgID uint64, msg proto.Message) error {
	body, err := proto.Marshal(msg)
	if err != nil {
		return errors.Trace(err)
	}
	var header [msgHeaderSize]byte
	binary.BigEndian.PutUint16(header[0:2], msgMagic)
	binary.BigEndian.PutUint16(header[2:4], msgVersion)
	binary.BigEndian.PutUint32(header[4:8], uint32(len(body)))
	binary.BigEndian.PutUint64(header[8:16], msgID)
	if _, err = w.Write(header[:]); err != nil {
		return errors.Trace(err)
	}
	_, err = w.Write(body)
	return errors.Trace(err)
}
func WriteMessage ( w io . Writer , msgID uint64 , msg proto . Message ) error { body , err := proto . Marshal ( msg ) if err != nil { return errors . Trace ( err ) } var header [ msgHeaderSize ] byte binary . BigEndian . PutUint16 ( header [ 0 : 2 ] , msgMagic ) binary . BigEndian . PutUint16 ( header [ 2 : 4 ] , msgVersion ) binary . BigEndian . PutUint32 ( header [ 4 : 8 ] , uint32 ( len ( body ) ) ) binary . BigEndian . PutUint64 ( header [ 8 : 16 ] , msgID ) if _ , err = w . Write ( header [ : ] ) ; err != nil { return errors . Trace ( err ) } _ , err = w . Write ( body ) return errors . Trace ( err ) }
WriteMessage writes a protocol buffer message to writer.
WriteMessage writes a protocol buffer message to writer .