Пример #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
	}
	bytesRead, err = encoding.ReadInt(reader, &reply.MaxBatch)
	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
	}
	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
	}
	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 = DeliverStatus(rawStatus)
	return
}
Пример #5
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
}