// 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 HELO reply to CN socket.
func (helo *NodeHelo) WriteNodeReply(writer io.Writer) (written int64, err error) {
	bytesWritten, err := common.WriteHeader(writer, HeaderNodeHelo)
	written += bytesWritten
	if err != nil {
		return
	}
	bytesWritten, err = common.WriteInt(writer, helo.Version)
	written += bytesWritten
	if err != nil {
		return
	}
	return
}
Beispiel #3
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
}
Beispiel #4
0
// OR writes HELO reply to Service socket.
func (helo *ServiceHelo) WriteServiceReply(writer io.Writer) (written int64, err error) {
	bytesWritten, err := common.WriteHeader(writer, HeaderServiceHelo)
	written += bytesWritten
	if err != nil {
		return
	}
	bytesWritten, err = common.WriteInt(writer, helo.Version)
	written += bytesWritten
	if err != nil {
		return
	}
	bytesWritten, err = common.WriteInt(writer, helo.MaxBatch)
	written += bytesWritten
	if err != nil {
		return
	}
	return
}
Beispiel #5
0
// Service writes HELO packet to OR socket. Useful for tests and Go services.
func (helo *ServiceHelo) WriteServiceRequest(writer io.Writer) (written int64, err error) {
	bytesWritten, err := common.WriteHeader(writer, HeaderServiceHelo)
	written += bytesWritten
	if err != nil {
		return
	}
	bytesWritten, err = common.WriteInt(writer, helo.Version)
	written += bytesWritten
	if err != nil {
		return
	}
	bytesWritten, err = common.WriteString(writer, helo.ServiceName)
	written += bytesWritten
	if err != nil {
		return
	}
	return
}
Beispiel #6
0
func (request *ConnChange) WriteNodeRequest(writer io.Writer) (written int64, err error) {
	bytesWritten, err := common.WriteHeader(writer, HeaderNodeConnChange)
	written += bytesWritten
	if err != nil {
		return
	}
	bytesWritten, err = common.WriteDevice(writer, request.DeviceId)
	written += bytesWritten
	if err != nil {
		return
	}
	bytesWritten, err = common.WriteInt(writer, request.Change)
	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 #8
0
func (request *DeviceList) WriteNodeRequest(writer io.Writer) (written int64, err error) {
	bytesWritten, err := common.WriteHeader(writer, HeaderNodeDeviceList)
	written += bytesWritten
	if err != nil {
		return
	}
	length := len(request.Devices)
	bytesWritten, err = common.WriteInt(writer, length)
	written += bytesWritten
	if err != nil {
		return
	}
	for _, device := range request.Devices {
		bytesWritten, err = common.WriteDevice(writer, device)
		written += bytesWritten
		if err != nil {
			return
		}
	}
	return
}
Beispiel #9
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
}