Class: default
Defined in: src/lib/messages/PatchSender/index.ts:86
Sends the user's drawing as patches. Shortly after any change (and once whenIdle runs it), it flattens the
user's own layers, compares the result with what it last sent, and sends only the area that changed. This covers every kind of change (strokes,
erasing, moving pixels, layer settings and order) without each tool reporting what it changed.
Example
const sync = new PatchSender({ width, height, layers: () => canvas.layers.layers, send, createCanvas });
app.layers.addEventListener("change", () => sync.schedule());
Constructors
Constructor
new default(
options):PatchSender
Defined in: src/lib/messages/PatchSender/index.ts:102
Parameters
options
Returns
PatchSender
Methods
markSent()
markSent(
area,rgba):void
Defined in: src/lib/messages/PatchSender/index.ts:157
Count pixels as already sent (e.g. the user's earlier work, restored from a shared drawing's history), so they aren't sent again.
Parameters
area
rgba
Uint8ClampedArray
Returns
void
schedule()
schedule():
void
Defined in: src/lib/messages/PatchSender/index.ts:114
Send the changes soon (changes within the delay go together), once whenIdle runs the sync.
Returns
void
stop()
stop():
void
Defined in: src/lib/messages/PatchSender/index.ts:170
Stop any pending sync.
Returns
void
sync()
sync():
Promise<void>
Defined in: src/lib/messages/PatchSender/index.ts:127
Send what changed since the last sync now. Resolves once sent; if sending fails, the changes go with the next sync.
Returns
Promise<void>