Exemplo n.º 1
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
}
Exemplo n.º 2
0
// CN writes HELO packet to OR socket.
func (helo *NodeHelo) WriteNodeRequest(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
	}
	bytesWritten, err = common.WriteInt(writer, helo.MaxBatch)
	written += bytesWritten
	if err != nil {
		return
	}
	return
}
Exemplo n.º 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
}
Exemplo n.º 4
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
}
Exemplo n.º 5
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
}
Exemplo n.º 6
0
// 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
}
Exemplo n.º 7
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
}