示例#1
0
// IR reads device change request from CN socket.
func (request *DeviceChangeRequest) ReadNodeRequest(reader io.Reader) (read int64, err error) {
	bytesRead, err := common.ExpectHeader(reader, HeaderNodeDeviceChange)
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = common.ReadUUID(reader, &request.MessageId)
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = common.ReadDevice(reader, &request.Current)
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = common.ReadDevice(reader, &request.Previous)
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = common.ReadString(reader, &request.ServiceName)
	read += bytesRead
	if err != nil {
		return
	}
	return
}
示例#2
0
func (request *DeviceList) ReadNodeRequest(reader io.Reader) (read int64, err error) {
	bytesRead, err := common.ExpectHeader(reader, HeaderNodeDeviceList)
	read += bytesRead
	if err != nil {
		return
	}
	var length int
	bytesRead, err = common.ReadInt(reader, &length)
	read += bytesRead
	if err != nil {
		return
	}
	devices := make([]common.Device, length)
	for index := 0; index < length; index++ {
		device := new(common.Device)
		bytesRead, err = common.ReadDevice(reader, device)
		read += bytesRead
		if err != nil {
			return
		}
		devices[index] = *device
	}
	request.Devices = devices
	return
}
示例#3
0
func (request *ConnChange) ReadNodeRequest(reader io.Reader) (read int64, err error) {
	bytesRead, err := common.ExpectHeader(reader, HeaderNodeConnChange)
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = common.ReadDevice(reader, &request.DeviceId)
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = common.ReadInt(reader, &request.Change)
	read += bytesRead
	if err != nil {
		return
	}
	return
}
示例#4
0
// OR reads delivery request from Service socket.
func (request *DeliverRequest) ReadServiceRequest(reader io.Reader) (read int64, err error) {
	bytesRead, err := common.ExpectHeader(reader, HeaderServiceDeliver)
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = common.ReadUUID(reader, &request.MessageId)
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = common.ReadDevice(reader, &request.DeviceId)
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = common.ReadString(reader, &request.Data)
	read += bytesRead
	if err != nil {
		return
	}
	return
}