Skip to content

Commit

Permalink
fix for url encoding issue?
Browse files Browse the repository at this point in the history
  • Loading branch information
howardchung committed Feb 7, 2025
1 parent 501c7f3 commit f514a97
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,14 @@ if (config.SSL_KEY_FILE && config.SSL_CRT_FILE) {
}
const io = new Server(server, { cors: {}, transports: ['websocket'] });
io.engine.use(async (req: any, res: Response, next: () => void) => {
const key = req._query.roomId;
if (!key) {
const roomId = req._query.roomId;
if (!roomId) {
return next();
}
// Attempt to ensure the room being connected to is loaded in memory
// If it doesn't exist, we may fail later with "invalid namespace"
const shard = resolveShard(key.slice(1));
const shard = resolveShard(roomId);
const key = '/' + roomId;
// Check to make sure this shard should load this room
const isCorrectShard = !config.SHARD || shard === config.SHARD;
if (isCorrectShard && postgres && !rooms.has(key)) {
Expand All @@ -82,7 +83,11 @@ io.engine.use(async (req: any, res: Response, next: () => void) => {
if (data) {
const room = new Room(io, key, data);
rooms.set(key, room);
console.log('loading room %s into memory on shard %s', key, config.SHARD);
console.log(
'loading room %s into memory on shard %s',
roomId,
config.SHARD,
);
}
}
next();
Expand Down
2 changes: 1 addition & 1 deletion src/components/App/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ export default class App extends React.Component<AppProps, AppState> {
uid: this.context.user?.uid,
token: await this.context.user?.getIdToken(),
shard,
roomId,
roomId: roomId.slice(1),
},
});
this.socket = socket;
Expand Down

0 comments on commit f514a97

Please sign in to comment.