Esempio n. 1
0
// CN writes delivery request to IR socket.
func (request *DeliverRequest) WriteNodeRequest(writer io.Writer) (written int64, err error) {
	bytesWritten, err := common.WriteHeader(writer, HeaderNodeDeliver)
	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.Device)
	written += bytesWritten
	if err != nil {
		return
	}
	bytesWritten, err = common.WriteString(writer, request.ServiceName)
	written += bytesWritten
	if err != nil {
		return
	}
	bytesWritten, err = common.WriteString(writer, request.Data)
	written += bytesWritten
	if err != nil {
		return
	}
	return
}
Esempio n. 2
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
}