多人匹配时, 返回当前记录的id
This commit is contained in:
parent
c0cba8d9ad
commit
4ab3fee323
@ -117,6 +117,7 @@
|
||||
"roomId": "mysWNuFnY", //房间id
|
||||
"beginTime": 1619689073034, // 游戏的开始时间
|
||||
"sessionId": "adfadf" // 当前用户在该房间的sessionId, 如果有该字段, 客户端在joinById的时候须带上该字段
|
||||
"session": "608baeea9d0fe70ccd54cf9c" // 当前局的id,提交答案时必须上报该字段
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -152,6 +152,7 @@ class PuzzleController extends BaseController {
|
||||
|
||||
let roomId = ''
|
||||
let sessionId = ''
|
||||
let sessionMatch = ''
|
||||
let beginTime = 0
|
||||
let result = new RoomState().isLock(shop)
|
||||
try {
|
||||
@ -163,6 +164,7 @@ class PuzzleController extends BaseController {
|
||||
let history = await PuzzleSession.findOne({ shop, status: {$in: [0, 1]}, type: 1 })
|
||||
if (history && !history.hasExpired()) {
|
||||
beginTime = history.begin
|
||||
sessionMatch = history.id
|
||||
if (!history.members.has(accountid)) {
|
||||
let rsp = await joinRoom({roomId: history.room})
|
||||
if (rsp.status != 200) {
|
||||
@ -184,7 +186,6 @@ class PuzzleController extends BaseController {
|
||||
new RoomState().unlock(shop)
|
||||
return
|
||||
}
|
||||
|
||||
} else {
|
||||
let rsp = await createRoom(data)
|
||||
if (rsp.status != 200) {
|
||||
@ -205,6 +206,7 @@ class PuzzleController extends BaseController {
|
||||
history.expire = history.begin + (100 || 90) * 1000
|
||||
history.type = 1
|
||||
await history.save()
|
||||
sessionMatch = history.id
|
||||
new Schedule().beginSchedule(beginSecond, async function () {
|
||||
await startGame(roomId, history.id)
|
||||
}, shop)
|
||||
@ -218,6 +220,6 @@ class PuzzleController extends BaseController {
|
||||
throw new ZError(12, 'error create room')
|
||||
}
|
||||
|
||||
return { roomId, beginTime,sessionId }
|
||||
return { roomId, beginTime,sessionId, session: sessionMatch }
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user