Skip to content

Commit

Permalink
socket js 긴급수정
Browse files Browse the repository at this point in the history
  • Loading branch information
hyeonseokang committed Dec 1, 2023
1 parent 2833cdf commit da6f448
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,27 +74,28 @@ module.exports = (server) => {
});

socket.on(Info.EVENT_MESSAGE.MATCH_START, async(deckIndex)=>{
setTimeout(()=>{
const userState = await UserState.findOne({
where:{
'socketId':socket.id,
'state':Info.userState.Join,
}
});

if(userState != null){
if(userState.state != Info.userState.Join)
return;

if(deckIndex == "")
deckIndex = 1;
socket.deckIndex = deckIndex;
console.log(socket.id, " 매칭 시작함");
userState.state = Info.userState.Match;
await userState.save();
socket.emit(Info.EVENT_MESSAGE.MATCH_START, "");
}
await setTimeout(() => {

}, 2000);
const userState = await UserState.findOne({
where:{
'socketId':socket.id,
'state':Info.userState.Join,
}
});

if(userState != null){
if(userState.state != Info.userState.Join)
return;

if(deckIndex == "")
deckIndex = 1;
socket.deckIndex = deckIndex;
console.log(socket.id, " 매칭 시작함");
userState.state = Info.userState.Match;
await userState.save();
socket.emit(Info.EVENT_MESSAGE.MATCH_START, "");
}
});
socket.on(Info.EVENT_MESSAGE.MATCH_CANCEL, async ()=>{
const userState = await UserState.findOne({
Expand Down

0 comments on commit da6f448

Please sign in to comment.