-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated matcher algorithm updated the other
- Loading branch information
1 parent
23004c4
commit 54d2587
Showing
10 changed files
with
404 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import userModel from "@/models/userModel"; | ||
import connectDB from "@/lib/connectDB"; | ||
|
||
|
||
export async function handleLeave(req, res) { | ||
|
||
try { | ||
|
||
const { socketId } = req.body; | ||
|
||
await connectDB(); | ||
const user = await userModel.findOne({ "socketInfo.id": socketId }); | ||
|
||
if (!user) { | ||
return res.status(400).json({ success: false, message: "User not found" }); | ||
} | ||
|
||
|
||
|
||
user.socketInfo.online = false; | ||
user.socketInfo.roomName = ""; | ||
user.socketInfo.id = ""; | ||
|
||
await user.save(); | ||
|
||
res.status(200).json({ success: true, message: "User left the room" }); | ||
} catch (error) { | ||
console.log(error); | ||
res.status(400).json({ success: false, message: error.message }); | ||
} | ||
|
||
} |
Oops, something went wrong.