Skip to content

Commit

Permalink
Add message id
Browse files Browse the repository at this point in the history
Signed-off-by: Marcos Candeia <[email protected]>
  • Loading branch information
mcandeia committed Mar 9, 2024
1 parent 43c4092 commit 2bda625
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/realtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export interface JSONFilePatch extends BaseFilePatch {
}

export interface VolumePatchRequest {
messageId?: string;
patches: FilePatch[];
}

Expand All @@ -72,6 +73,7 @@ export interface VolumePatchResponse {
}

export interface FsEvent {
messageId?: string;
path: string;
deleted?: boolean;
timestamp: number;
Expand Down Expand Up @@ -343,7 +345,7 @@ export class Realtime implements DurableObject {
return new Response(null, { status: 204 });
},
PATCH: async (req: Request) => {
const { patches } = await req.json() as VolumePatchRequest;
const { patches, messageId } = await req.json() as VolumePatchRequest;

const results: FilePatchResult[] = [];

Expand Down Expand Up @@ -431,7 +433,12 @@ export class Realtime implements DurableObject {
if (shouldBroadcast) {
for (const result of results) {
const { path, deleted } = result;
this.broadcast({ path, timestamp: this.timestamp, deleted });
this.broadcast({
messageId,
path,
timestamp: this.timestamp,
deleted,
});
}
}
}
Expand Down

0 comments on commit 2bda625

Please sign in to comment.