Пример #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
}
Пример #2
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
}
Пример #3
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
}
Пример #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
}
Пример #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
}
Пример #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
}
Пример #7
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
}
Пример #8
0
func (request *DeviceChangeRequest) 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.Current.ClusterId, &request.Current.DeviceId)
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = encoding.ReadCSUUID(reader, &request.Previous.ClusterId, &request.Previous.DeviceId)
	read += bytesRead
	if err != nil {
		return
	}
	return
}