Exemple #1
0
func (deviceList *DeviceList) ReadFrom(reader io.Reader) (read int64, err error) {
	bytesRead, err := encoding.ExpectHeader(reader, deviceList.Header())
	read += bytesRead
	if err != nil {
		return
	}
	var length int
	bytesRead, err = encoding.ReadInt(reader, &length)
	read += bytesRead
	if err != nil {
		return
	}
	devices := make([]encoding.Device, length)
	for index := 0; index < length; index++ {
		device := *new(encoding.Device)
		bytesRead, err = encoding.ReadCSUUID(reader, &device.ClusterId, &device.DeviceId)
		read += bytesRead
		if err != nil {
			return
		}
		devices[index] = device
	}
	deviceList.Devices = devices
	return
}
Exemple #2
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.ReadInt(reader, &request.MaxBatch)
	read += bytesRead
	if err != nil {
		return
	}
	return
}
Exemple #3
0
func (reply *HeloReply) ReadFrom(reader io.Reader) (read int64, err error) {
	bytesRead, err := encoding.ExpectHeader(reader, reply.Header())
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = encoding.ReadInt(reader, &reply.Version)
	read += bytesRead
	if err != nil {
		return
	}
	return
}
Exemple #4
0
func (reply *DeliverReply) ReadFrom(reader io.Reader) (read int64, err error) {
	bytesRead, err := encoding.ExpectHeader(reader, reply.Header())
	read += bytesRead
	if err != nil {
		return
	}
	var rawSuccess int
	bytesRead, err = encoding.ReadInt(reader, &rawSuccess)
	read += bytesRead
	if err != nil {
		return
	}
	reply.Success = DeliveryStatus(rawSuccess)
	bytesRead, err = encoding.ReadUUID(reader, &reply.MessageId)
	read += bytesRead
	if err != nil {
		return
	}
	return
}
Exemple #5
0
func (reply *DeviceChangeReply) ReadFrom(reader io.Reader) (read int64, err error) {
	bytesRead, err := encoding.ExpectHeader(reader, reply.Header())
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = encoding.ReadUUID(reader, &reply.MessageId)
	read += bytesRead
	if err != nil {
		return
	}
	var rawStatus int
	bytesRead, err = encoding.ReadInt(reader, &rawStatus)
	read += bytesRead
	if err != nil {
		return
	}
	reply.Status = ChangeStatus(rawStatus)
	return
}
Exemple #6
0
func (connChange *ConnChange) ReadFrom(reader io.Reader) (read int64, err error) {
	bytesRead, err := encoding.ExpectHeader(reader, connChange.Header())
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = encoding.ReadCSUUID(reader, &connChange.ClusterId, &connChange.DeviceId)
	read += bytesRead
	if err != nil {
		return
	}
	var rawStatus int
	bytesRead, err = encoding.ReadInt(reader, &rawStatus)
	read += bytesRead
	if err != nil {
		return
	}
	connChange.Status = ConnStatus(rawStatus)
	return
}