Skip to content
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

fix(client-presence): Rename ISessionClient so that function/property naming is consistent #22889

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ function makePresenceView(
logContentDiv.style.border = "1px solid black";
if (audience !== undefined) {
presenceConfig.presence.events.on("attendeeJoined", (attendee) => {
const name = audience.getMembers().get(attendee.connectionId())?.name;
const name = audience.getMembers().get(attendee.getConnectionId())?.name;
const update = `client ${name === undefined ? "(unnamed)" : `named ${name}`} with id ${attendee.sessionId} joined`;
addLogEntry(logContentDiv, update);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export interface IPresence {

// @alpha @sealed
export interface ISessionClient<SpecificSessionClientId extends ClientSessionId = ClientSessionId> {
connectionId(): ClientConnectionId;
getConnectionId(): ClientConnectionId;
getStatus(): SessionClientStatus;
// (undocumented)
readonly sessionId: SpecificSessionClientId;
Expand Down
2 changes: 1 addition & 1 deletion packages/framework/presence/src/baseTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* Each client connection is given a unique identifier for the duration of the
* connection. If a client disconnects and reconnects, it will be given a new
* identifier. Prefer use of {@link ISessionClient} as a way to identify clients
* in a session. {@link ISessionClient.connectionId} will provide the current
* in a session. {@link ISessionClient.getConnectionId} will provide the current
* connection identifier for a logical session client.
*
* @privateRemarks
Expand Down
2 changes: 1 addition & 1 deletion packages/framework/presence/src/presence.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export interface ISessionClient<
*
* If {@link ISessionClient.getStatus} is {@link (SessionClientStatus:variable).Disconnected}, this will represent the last known connection id.
*/
connectionId(): ClientConnectionId;
getConnectionId(): ClientConnectionId;

/**
* Get status of session client.
Expand Down
12 changes: 6 additions & 6 deletions packages/framework/presence/src/systemWorkspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export interface SystemWorkspaceDatastore {
/**
* There is no implementation class for this interface.
* It is a simple structure. Most complicated aspect is that
* `connectionId()` member is replaced with a new
* `getConnectionId()` member is replaced with a new
* function when a more recent connection is added.
*
* See {@link SystemWorkspaceImpl.ensureAttendee}.
Expand Down Expand Up @@ -89,7 +89,7 @@ class SystemWorkspaceImpl implements PresenceStatesInternal, SystemWorkspace {
this.selfAttendee = {
sessionId: clientSessionId,
order: 0,
connectionId: () => {
getConnectionId: () => {
throw new Error("Client has never been connected");
},
getStatus: () => SessionClientStatus.Disconnected,
Expand Down Expand Up @@ -150,7 +150,7 @@ class SystemWorkspaceImpl implements PresenceStatesInternal, SystemWorkspace {
value: this.selfAttendee.sessionId,
};

this.selfAttendee.connectionId = () => clientConnectionId;
this.selfAttendee.getConnectionId = () => clientConnectionId;
this.selfAttendee.getStatus = () => SessionClientStatus.Connected;
this.attendees.set(clientConnectionId, this.selfAttendee);
}
Expand All @@ -163,7 +163,7 @@ class SystemWorkspaceImpl implements PresenceStatesInternal, SystemWorkspace {

// If the last known connectionID is different from the connection id being removed, the attendee has reconnected,
// therefore we should not change the attendee connection status or emit a disconnect event.
const attendeeReconnected = attendee.connectionId() !== clientConnectionId;
const attendeeReconnected = attendee.getConnectionId() !== clientConnectionId;
if (!attendeeReconnected) {
attendee.getStatus = () => SessionClientStatus.Disconnected;
this.events.emit("attendeeDisconnected", attendee);
Expand Down Expand Up @@ -210,7 +210,7 @@ class SystemWorkspaceImpl implements PresenceStatesInternal, SystemWorkspace {
attendee = {
sessionId: clientSessionId,
order,
connectionId,
getConnectionId: connectionId,
getStatus: () => SessionClientStatus.Connected,
};
this.attendees.set(clientSessionId, attendee);
Expand All @@ -219,7 +219,7 @@ class SystemWorkspaceImpl implements PresenceStatesInternal, SystemWorkspace {
// The given association is newer than the one we have.
// Update the order and current connection id.
attendee.order = order;
attendee.connectionId = connectionId;
attendee.getConnectionId = connectionId;
}
// Always update entry for the connection id. (Okay if already set.)
this.attendees.set(clientConnectionId, attendee);
Expand Down
6 changes: 3 additions & 3 deletions packages/framework/presence/src/test/presenceManager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ describe("Presence", () => {
"Attendee has wrong session id",
);
assert.equal(
newAttendee.connectionId(),
newAttendee.getConnectionId(),
initialAttendeeConnectionId,
"Attendee has wrong client connection id",
);
Expand Down Expand Up @@ -163,7 +163,7 @@ describe("Presence", () => {
"Disconnected attendee has wrong session id",
);
assert.equal(
disconnectedAttendee.connectionId(),
disconnectedAttendee.getConnectionId(),
initialAttendeeConnectionId,
"Disconnected attendee has wrong client connection id",
);
Expand Down Expand Up @@ -251,7 +251,7 @@ describe("Presence", () => {
);
// Current connection id is updated
assert(
newAttendee.connectionId() === updatedClientConnectionId,
newAttendee.getConnectionId() === updatedClientConnectionId,
"Attendee does not have updated client connection id",
);
// Attendee is available via new connection id
Expand Down
Loading