Skip to content

feat(client-presence): Create Acknowledgment message interface and ackRequested flow #24470

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 21 commits into from
Jun 2, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions packages/framework/presence/src/presenceDatastoreManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,7 @@ const acknowledgementMessageType = "Pres:Ack";

interface AcknowledgementMessage extends IInboundSignalMessage {
type: typeof acknowledgementMessageType;
content: {
sendTimestamp: number;
avgLatency: number;
};
content: unknown;
}

function isPresenceMessage(
Expand Down Expand Up @@ -378,6 +375,14 @@ export class PresenceDatastoreManagerImpl implements PresenceDatastoreManager {
if (!isPresenceMessage(message)) {
return;
}

// Here we accept acknowledgement messages passively.
// Once implemented, these will be used for tracking message delivery status.
// For now, we just skip processing these messages.
if (message.type === acknowledgementMessageType) {
return;
}

if (local) {
const deliveryDelta = received - message.content.sendTimestamp;
// Limit returnedMessages count to 256 such that newest message
Expand All @@ -404,9 +409,6 @@ export class PresenceDatastoreManagerImpl implements PresenceDatastoreManager {
}
// It is okay to continue processing the contained updates even if we are not
// connected.
} else if (message.type === acknowledgementMessageType) {
// TODO: Handle acknowledgement message type.
return;
} else {
assert(message.type === datastoreUpdateMessageType, 0xa3b /* Unexpected message type */);
if (message.content.isComplete) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,5 +438,29 @@ describe("Presence", () => {
assert.strictEqual(listener.callCount, 1);
});
});

describe("receiving AcknowledgementMessage", () => {
it("accpets passively without failing", () => {
const presence = prepareConnectedPresence(
runtime,
"attendeeId-2",
"client2",
clock,
logger,
);

presence.processSignal(
"",
{
type: "Pres:Ack",
content: {
messageId: "messageId",
},
clientId: "client1",
},
false,
);
});
});
});
});
Loading