pokemon-showdown icon indicating copy to clipboard operation
pokemon-showdown copied to clipboard

Propagate command promises

Open mia-pi-git opened this issue 3 years ago • 4 comments

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.

mia-pi-git avatar Dec 05 '21 05:12 mia-pi-git

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?

AnnikaCodes avatar Dec 14 '21 23:12 AnnikaCodes

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.

mia-pi-git avatar Dec 14 '21 23:12 mia-pi-git

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.

AnnikaCodes avatar Dec 14 '21 23:12 AnnikaCodes

Bumping this, updated to latest code and fixed conflicts.

mia-pi-git avatar Apr 25 '23 15:04 mia-pi-git