Class NearbyPayload
- Namespace
- Plugin.Maui.NearbyConnectivity
- Assembly
- Plugin.Maui.NearbyConnectivity.dll
Represents data sent to, or received from, a nearby device.
[SuppressMessage("Design", "CA1063:Implement IDisposable Correctly", Justification = "The payload shapes are a closed set with no finalizer; DisposeCore is the private-protected override point.")]
public abstract class NearbyPayload : IDisposable
- Inheritance
-
NearbyPayload
- Implements
- Derived
- Inherited Members
Remarks
The abstract base for every payload shape the plugin produces or accepts: NearbyBytesPayload, NearbyFilePayload, and NearbyStreamPayload. Switch on the concrete type to handle one.
A class, not a record. A payload owns a resource such as a buffer, a staged file, or a live stream, so reference identity is the correct equality for it. Value equality over a payload would compare handles rather than contents and quietly report two different files as equal.
Dispose what you receive. Disposing a received payload releases what it holds: a stream
payload closes its stream, a file payload deletes its staged file unless
MoveTo(string) already moved it, and a byte payload holds
nothing. A using in the receive loop is enough for a loop that handles every shape. Read
or move the content first: after disposal the stream is closed and the staged file is gone.
Methods
Dispose()
Releases the stream or staged file this payload holds.
public void Dispose()
Remarks
Safe to call more than once, and never throws. A staged file that cannot be deleted now is deleted when the session stops. The plugin disposes any payload still undelivered when its connection closes.