Skip to content

Commit

Permalink
removed scene bounds cache
Browse files Browse the repository at this point in the history
  • Loading branch information
barnabasmolnar committed Dec 13, 2023
1 parent 01e78bf commit 511f784
Showing 1 changed file with 0 additions and 27 deletions.
27 changes: 0 additions & 27 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,6 @@ try {
allowEIO3: true,
});

// we want to keep track of the last position of the followed user's scene
// bounds so that we can send it to the new follower without having to
// make an interaction on the scene
const withLatestSceneBounds = new Map<
string,
{ data: ArrayBuffer; iv: Uint8Array }
>();

io.on("connection", (socket) => {
ioDebug("connection established!");
io.to(`${socket.id}`).emit("init-room");
Expand Down Expand Up @@ -85,9 +77,6 @@ try {
socket.on(
"server-volatile-broadcast",
(roomID: string, encryptedData: ArrayBuffer, iv: Uint8Array) => {
if (roomID.startsWith("follow_")) {
withLatestSceneBounds.set(roomID, { data: encryptedData, iv });
}
socketDebug(`${socket.id} sends volatile update to ${roomID}`);
socket.volatile.broadcast
.to(roomID)
Expand All @@ -101,17 +90,6 @@ try {
case "follow":
await socket.join(roomID);

// Immediately send the latest scene bounds to the new follower
// without having to wait for a scene interaction
const latestSceneBounds = withLatestSceneBounds.get(roomID);
if (latestSceneBounds) {
io.to(socket.id).emit(
"client-broadcast",
latestSceneBounds.data,
latestSceneBounds.iv,
);
}

const sockets = await io.in(roomID).fetchSockets();
const followedBy = sockets.map((socket) => socket.id);

Expand All @@ -134,11 +112,6 @@ try {
_followedBy,
);

// cleanup
if (_sockets.length === 0) {
withLatestSceneBounds.delete(roomID);
}

break;
}
});
Expand Down

0 comments on commit 511f784

Please sign in to comment.