fix possible lost messages (OOS)
This commit is contained in:
parent
c6f47c9b25
commit
472113ad74
6 changed files with 21 additions and 10 deletions
1
build/public/assets/index.4d785533.js
Normal file
1
build/public/assets/index.4d785533.js
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
|
@ -4,7 +4,7 @@
|
|||
<meta charset="UTF-8">
|
||||
|
||||
<title>🧩 jigsaw.hyottoko.club</title>
|
||||
<script type="module" crossorigin src="/assets/index.ae0a2617.js"></script>
|
||||
<script type="module" crossorigin src="/assets/index.4d785533.js"></script>
|
||||
<link rel="modulepreload" href="/assets/vendor.b622ee49.js">
|
||||
<link rel="stylesheet" href="/assets/index.f7304069.css">
|
||||
</head>
|
||||
|
|
|
|||
|
|
@ -2027,7 +2027,7 @@ app.post('/api/upload', (req, res) => {
|
|||
res.send(Images.imageFromDb(db, imageId));
|
||||
});
|
||||
});
|
||||
app.post('/newgame', express.json(), async (req, res) => {
|
||||
app.post('/api/newgame', express.json(), async (req, res) => {
|
||||
const gameSettings = req.body;
|
||||
log.log(gameSettings);
|
||||
const gameId = Util.uniqId();
|
||||
|
|
|
|||
|
|
@ -16,19 +16,31 @@ const CONN_STATE_CONNECTING = 3 // connecting
|
|||
const CONN_STATE_CLOSED = 4 // not connected (closed on purpose)
|
||||
|
||||
let ws: WebSocket
|
||||
|
||||
let missedMessages: Array<any> = []
|
||||
let changesCallback = (msg: Array<any>) => {
|
||||
// empty
|
||||
}
|
||||
let connectionStateChangeCallback = (state: number) => {
|
||||
// empty
|
||||
missedMessages.push(msg)
|
||||
}
|
||||
|
||||
let missedStateChanges: Array<number> = []
|
||||
let connectionStateChangeCallback = (state: number) => {
|
||||
missedStateChanges.push(state)
|
||||
}
|
||||
|
||||
// TODO: change these to something like on(EVT, cb)
|
||||
function onServerChange(callback: (msg: Array<any>) => void): void {
|
||||
changesCallback = callback
|
||||
for (const missedMessage of missedMessages) {
|
||||
changesCallback(missedMessage)
|
||||
}
|
||||
missedMessages = []
|
||||
}
|
||||
|
||||
function onConnectionStateChange(callback: (state: number) => void): void {
|
||||
connectionStateChangeCallback = callback
|
||||
for (const missedStateChange of missedStateChanges) {
|
||||
connectionStateChangeCallback(missedStateChange)
|
||||
}
|
||||
missedStateChanges = []
|
||||
}
|
||||
|
||||
let connectionState = CONN_STATE_NOT_CONNECTED
|
||||
|
|
@ -48,7 +60,6 @@ function send(message: ClientEvent): void {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
let clientSeq: number
|
||||
let events: Record<number, GameEvent>
|
||||
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ app.post('/api/upload', (req, res) => {
|
|||
})
|
||||
})
|
||||
|
||||
app.post('/newgame', express.json(), async (req, res) => {
|
||||
app.post('/api/newgame', express.json(), async (req, res) => {
|
||||
const gameSettings = req.body as GameSettings
|
||||
log.log(gameSettings)
|
||||
const gameId = Util.uniqId()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue