zplCore.comzplCore.com

NucleusPrinterConnection

public sealed class NucleusPrinterConnection : IPrinterConnection, IAsyncDisposable

Prints through Zebra Nucleus (Zebra Cloud Print API) to a printer anywhere – the printer only needs its WebLink connection to the Nucleus tenant, no network route from here. Drop-in for every IPrinterConnection use: await using var printer = new NucleusPrinterConnection("XXZJJ174600974"); // token from ZEBRA_NUCLEUS_TOKEN await label.For<Shipment>().PrintAsync(printer, shipments);NucleusPrinterConnection.SendAsync submits one print job per call and throws when the printer refuses it (missing licence, unknown serial number …). NucleusPrinterConnection.LastJobId and NucleusPrinterConnection.LastAlerts describe the last job; with NucleusPrinterConnection.WaitForCompletion each send also waits until the job completed. NucleusPrinterConnection.QueryAsync returns null: the API has no live status query (status comes as the printer's alerts with each print).

Constructors

SignatureDescription
# NucleusPrinterConnection(string serialNumber, NucleusCloudPrintOptions? options = default)Connection to one printer (serial number in the Nucleus tenant); token from the options or the environment.
# NucleusPrinterConnection(string serialNumber, string token)Connection to one printer with an explicit API token.
# NucleusPrinterConnection(NucleusCloudPrintClient client, string serialNumber)Connection over a shared client (several printers, one token).

Properties

PropertyTypeDescription
Client { get; }NucleusCloudPrintClient
CompletionTimeout { get; set; }TimeSpanTime limit for NucleusPrinterConnection.WaitForCompletion; on timeout the last state is reported, never a resend.
LastAlerts { get; }IReadOnlyList<NucleusAlert>The printer's alerts reported with the last print ("Paper out", "Head open" …).
LastJob { get; }NucleusPrintJobState of the last job when NucleusPrinterConnection.WaitForCompletion is on.
LastJobId { get; }stringJob id of the last accepted job.
SerialNumber { get; }string
WaitForCompletion { get; set; }boolWait after each send until the job is completed (failed/cancelled → exception). Default off: accepted = done.

Methods

Method SignatureReturnsDescription
# CancelLastAsync(CancellationToken ct = default)Task<bool>Cancels the last job if it is still pending (see NucleusCloudPrintClient.CancelAsync).
# DisposeAsync()ValueTask
# QueryAsync(string command, TimeSpan timeout, CancellationToken ct = default)Task<string>Always null: the Cloud Print API has no command/status channel. See NucleusPrinterConnection.LastAlerts.
# SendAsync(byte[] data, CancellationToken ct = default)Task
# ToString()string

Events

EventHandler TypeDescription
JobAcceptedAction<NucleusPrintResult>Raised for every accepted job (job id and alerts), e.g. to log it next to the own job.