you’re on your way 4
177
asynchronous applications
1Jim
coffeemaker.php
What do we do with the server’s response?
You’ve completed orderCoffee(), and now coffeemaker.php is
done. When you send a request to brew coffee to one of the coffee makers,
coffeemaker.php runs and then returns the coffee maker that completed the
order, as well as the name of the person who placed the order.
The server returns the coffee maker that
nished brewing, and then the name of the
person who placed the order.
When the browser gets a response
from the server, it will run the
callback you indicated: serveDrink().
serveDrink() needs to let the person
who placed the order know their
coffee is ready, and set the status of
the right coffee maker back to “Idle”.
coffee.js
serveDrink()
Make Jim a large mocha
using the rst coffee maker
Jim enters his coffee order, and
clicks “Order Coffee”.
coffee.js
orderCoffee()
orderCoffee()