pokemon-showdown
pokemon-showdown copied to clipboard
Propagate command promises
This PR removes User.chat and breaks its functionality into 3 parts.
- Chat.receive - takes a message, room, and connection, handles multiline messages, and parses everything apart to queue them up
- Chat.queue - puts messages into chat queue where applicable, parses them if not
- Chat.parse - as normal, parses commands.
Chat.parse now is
async
and awaits all commands that return promises.
If I'm understanding this correctly, asynchronous commands are only awaited by Chat.parse
if the user's chat queue is empty. Is that correct?
If I'm understanding this correctly, asynchronous commands are only awaited by
Chat.parse
if the user's chat queue is empty. Is that correct?
No, they're awaited both ways.
If I'm understanding this correctly, asynchronous commands are only awaited by
Chat.parse
if the user's chat queue is empty. Is that correct?No, they're awaited both ways.
} else if (now < user.lastChatMessage + throttleDelay) {
user.chatQueue = [[message, room ? room.roomid : '', connection]];
user.startChatQueue(throttleDelay - (now - user.lastChatMessage));
This... doesn't seem to await it - User#startChatQueue
just sets a timeout to parse the message later? I'm confused.
Bumping this, updated to latest code and fixed conflicts.