Ejemplo n.º 1
0
func (request *HeloRequest) ReadFrom(reader io.Reader) (read int64, err error) {
	bytesRead, err := encoding.ExpectHeader(reader, request.Header())
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = encoding.ReadInt(reader, &request.Version)
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = encoding.ReadString(reader, &request.Service, encoding.MaxServiceSize)
	read += bytesRead
	if err != nil {
		return
	}
	return
}
Ejemplo n.º 2
0
func (request *DeliverRequest) ReadFrom(reader io.Reader) (read int64, err error) {
	bytesRead, err := encoding.ExpectHeader(reader, request.Header())
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = encoding.ReadUUID(reader, &request.MessageId)
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = encoding.ReadCSUUID(reader, &request.ClusterId, &request.DeviceId)
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = encoding.ReadString(reader, &request.Data, encoding.MaxPayloadSize)
	read += bytesRead
	if err != nil {
		return
	}
	return
}