Ejemplo n.º 1
0
func Encode(encode_method string, v interface{}) *packet.Packet {
	protocol := NameToId[encode_method]
	buffer := packet.Writer()
	buffer.WriteUint16(protocol)
	encode_handlers[encode_method](buffer, v)
	return buffer
}
Ejemplo n.º 2
0
func (buf *Buffer) raw_send(data []byte) {
	writer := packet.Writer()
	writer.WriteUint16(uint16(len(data)))
	writer.WriteRawBytes(data)

	n, err := buf.conn.Write(writer.Data())
	if err != nil {
		ERR("Error send reply, bytes:", n, "reason:", err)
		return
	}
}