// CN writes device ID change request to IR socket.
func (request *DeviceChangeRequest) WriteNodeRequest(writer io.Writer) (written int64, err error) {
	bytesWritten, err := common.WriteHeader(writer, HeaderNodeDeviceChange)
	written += bytesWritten
	if err != nil {
		return
	}
	bytesWritten, err = common.WriteUUID(writer, request.MessageId)
	written += bytesWritten
	if err != nil {
		return
	}
	bytesWritten, err = common.WriteDevice(writer, request.Current)
	written += bytesWritten
	if err != nil {
		return
	}
	bytesWritten, err = common.WriteDevice(writer, request.Previous)
	written += bytesWritten
	if err != nil {
		return
	}
	bytesWritten, err = common.WriteString(writer, request.ServiceName)
	written += bytesWritten
	if err != nil {
		return
	}
	return
}
Beispiel #2
0
// OR writes message delivery ACK to Service socket.
func (reply *DeliverReply) WriteServiceReply(writer io.Writer) (written int64, err error) {
	bytesWritten, err := common.WriteHeader(writer, HeaderServiceDeliver)
	written += bytesWritten
	if err != nil {
		return
	}
	bytesWritten, err = common.WriteUUID(writer, reply.MessageId)
	written += bytesWritten
	if err != nil {
		return
	}
	bytesWritten, err = common.WriteInt(writer, reply.Response)
	written += bytesWritten
	if err != nil {
		return
	}
	return
}
// IR writes ACK to CN socket.
func (reply *DeviceChangeReply) WriteNodeReply(writer io.Writer) (written int64, err error) {
	bytesWritten, err := common.WriteHeader(writer, HeaderNodeDeviceChange)
	written += bytesWritten
	if err != nil {
		return
	}
	bytesWritten, err = common.WriteUUID(writer, reply.MessageId)
	written += bytesWritten
	if err != nil {
		return
	}
	// One of: `StatusNodeDelivered`, `StatusNodeSpooled`,
	// `StatusNodeUnavailable`.
	bytesWritten, err = common.WriteInt(writer, reply.Response)
	written += bytesWritten
	if err != nil {
		return
	}
	return
}
Beispiel #4
0
// Service writes delivery request to OR socket. Useful for tests and Go
// services.
func (request *DeliverRequest) WriteServiceRequest(writer io.Writer) (written int64, err error) {
	bytesWritten, err := common.WriteHeader(writer, HeaderServiceDeliver)
	written += bytesWritten
	if err != nil {
		return
	}
	bytesWritten, err = common.WriteUUID(writer, request.MessageId)
	written += bytesWritten
	if err != nil {
		return
	}
	bytesWritten, err = common.WriteDevice(writer, request.DeviceId)
	written += bytesWritten
	if err != nil {
		return
	}
	bytesWritten, err = common.WriteString(writer, request.Data)
	written += bytesWritten
	if err != nil {
		return
	}
	return
}