zplCore.comzplCore.com

NucleusCloudPrintClient

public sealed class NucleusCloudPrintClient : IDisposable

Client of the Zebra Cloud Print API (Zebra Nucleus): NucleusCloudPrintClient.PrintAsync (server-streaming Print, one result per printer), NucleusCloudPrintClient.GetJobAsync, NucleusCloudPrintClient.WaitAsync, NucleusCloudPrintClient.CancelAsync. gRPC over HTTP/2 with HttpClient only – no extra packages, NativeAOT-compatible. Printers are addressed by serial number; they must be enrolled in the token's Nucleus tenant (WebLink). Thread-safe; reuse one instance.
The message definitions come from NucleusCloudPrintOptions.DescriptorSetPath, else from gRPC server reflection, else from a built-in fallback (NucleusCloudPrintClient.SchemaSource). Calls go by field name, so the field numbers always come from those definitions.

Constructors

SignatureDescription
# NucleusCloudPrintClient(NucleusCloudPrintOptions? options = default)
# NucleusCloudPrintClient(string token)Convenience: client for a token.

Properties

PropertyTypeDescription
SchemaSource { get; }NucleusSchemaSourceWhere the message definitions came from (after the first call).

Methods

Method SignatureReturnsDescription
# CancelAsync(string jobId, CancellationToken ct = default)Task<bool>Cancels a pending job (CancelPrintJob). True = cancelled; false = not cancellable (already printed or final). Cancellation is not guaranteed once printing has started.
static # Crc32Hex(ReadOnlySpan<byte> data)stringCRC-32 (IEEE) of data as 8 lower-case hex digits, for NucleusCloudPrintClient.PrintRemoteFileAsync.
# Dispose()void
# GetJobAsync(string jobId, CancellationToken ct = default)Task<NucleusPrintJob>Status of a job (GetPrintJobStatus; the job id from NucleusCloudPrintClient.PrintAsync).
# PrintAsync(ReadOnlyMemory<byte> data, IReadOnlyList<string> serialNumbers, CancellationToken ct = default)Task<IReadOnlyList<NucleusPrintResult>>Sends data (ZPL or other raw printer data, at most 10 MB) to one or more printers. Returns one result per printer: the job id, or the printer's error (e.g. missing licence); call-wide errors throw NucleusException.
# PrintAsync(ReadOnlyMemory<byte> data, string serialNumber, CancellationToken ct = default)Task<NucleusPrintResult>Like NucleusCloudPrintClient.PrintAsync for one printer.
# PrintRemoteFileAsync(Uri uri, IReadOnlyList<string> serialNumbers, string? crc32 = default, CancellationToken ct = default)Task<IReadOnlyList<NucleusPrintResult>>Lets Nucleus download the print data from uri (https) instead of sending it inline – for data near or above 10 MB. crc32 is the optional checksum string of the file (RemoteFile.crc32); see NucleusCloudPrintClient.Crc32Hex. Errors: NucleusErrorKind.RemoteFile (not found / not accessible).
# WaitAsync(string jobId, TimeSpan timeout, CancellationToken ct = default)Task<NucleusPrintJob>Polls NucleusCloudPrintClient.GetJobAsync (1 s, growing to 10 s) until the job is final or timeout elapses (then the last state).