Esempio n. 1
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
}
Esempio n. 2
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
}
Esempio n. 3
0
// CN reads HELO reply from OR socket.
func (helo *NodeHelo) ReadNodeReply(reader io.Reader) (read int64, err error) {
	bytesRead, err := common.ExpectHeader(reader, HeaderNodeHelo)
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = common.ReadInt(reader, &helo.Version)
	read += bytesRead
	if err != nil {
		return
	}
	return
}
Esempio n. 4
0
// Service reads message delivery ACK from OR socket. Useful for tests and Go
// services.
func (reply *DeliverReply) ReadServiceReply(reader io.Reader) (read int64, err error) {
	bytesRead, err := common.ExpectHeader(reader, HeaderServiceDeliver)
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = common.ReadUUID(reader, &reply.MessageId)
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = common.ReadInt(reader, &reply.Response)
	read += bytesRead
	if err != nil {
		return
	}
	return
}
Esempio n. 5
0
// Service reads HELO reply from OR socket. Useful for tests and Go services.
func (helo *ServiceHelo) ReadServiceReply(reader io.Reader) (read int64, err error) {
	bytesRead, err := common.ExpectHeader(reader, HeaderServiceHelo)
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = common.ReadInt(reader, &helo.Version)
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = common.ReadInt(reader, &helo.MaxBatch)
	read += bytesRead
	if err != nil {
		return
	}
	return
}
Esempio n. 6
0
// OR reads HELO request from Service socket.
func (helo *ServiceHelo) ReadServiceRequest(reader io.Reader) (read int64, err error) {
	bytesRead, err := common.ExpectHeader(reader, HeaderServiceHelo)
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = common.ReadInt(reader, &helo.Version)
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = common.ReadString(reader, &helo.ServiceName)
	read += bytesRead
	if err != nil {
		return
	}
	return
}
Esempio n. 7
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
}
Esempio n. 8
0
// CN reads ACK from IR socket.
func (reply *DeviceChangeReply) ReadNodeReply(reader io.Reader) (read int64, err error) {
	bytesRead, err := common.ExpectHeader(reader, HeaderNodeDeviceChange)
	read += bytesRead
	if err != nil {
		return
	}
	bytesRead, err = common.ReadUUID(reader, &reply.MessageId)
	read += bytesRead
	if err != nil {
		return
	}
	// One of: `StatusNodeDelivered`, `StatusNodeSpooled`,
	// `StatusNodeUnavailable`.
	bytesRead, err = common.ReadInt(reader, &reply.Response)
	read += bytesRead
	if err != nil {
		return
	}
	return
}
Esempio n. 9
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
}