Skip to content

Asynchronous Functions

oliviajerdee edited this page Jan 12, 2023 · 1 revision

Asynchronous Functions

image

Figure 8: Example flowchart of asynchronous function

Project Constraints: One major constraint of this project is the inability to use any third party libraries. This prevents us from using a traditional database that would help deal with collisions. Our solution to dealing with this is combining the async() function with another function called collision() which will use the Math.random() function to determine which message will be stored first.

Collision() function behavior: When multiple users send a message, the time is noted. async() will accept the messages and then check if they were sent at the same time. If they were sent at the same time, the collision() function is called which will randomly assign a number 1-10 to each message. The messages are then stored in the JSON file starting from the lowest assigned number.

Clone this wiki locally