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

Matching service occasionally returns wrong room number for both users #37

Closed
Singa-pirate opened this issue Nov 8, 2024 · 2 comments
Closed
Assignees
Labels
bug Something isn't working

Comments

@Singa-pirate
Copy link

There are 2 different room numbers in MatchRecord
When a match is found, it occasionally return the wrong one that is not used in the session

@Singa-pirate Singa-pirate added the bug Something isn't working label Nov 8, 2024
@Singa-pirate Singa-pirate self-assigned this Nov 8, 2024
@Singa-pirate
Copy link
Author

Cause:
In matching service, the roomNumber and questionId are returned when match is found ("matched" event). This uses the data from the user who starts matching later.

io.to(socketId).emit("matched", {
  matchedWith: existingMatch.userId,
  roomNumber,
  questionId: question?.questionId,
});
io.to(existingMatch.socketId).emit("matched", {
  matchedWith: userId,
  roomNumber,
  questionId: question?.questionId,
});

When match is confirmed (""match_success") event, the roomNumber and questionId for the session is from the user who accepts the match earlier.

await prisma.sessionHistory.create({
  data: {
    roomNumber: matchedRecord.roomNumber,
    questionId: matchedRecord.questionId ?? userRecord.questionId ?? 0,
    isOngoing: true,
    userOneId: userRecord.userId,
    userTwoId: matchedRecord.userId,
  },
});

When these two users don't match, the roomNumber used is wrong.

@Singa-pirate
Copy link
Author

Closes with #40

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant