In this chapter, we will introduce the actor model by extending our shopping project. The extension will consist of a notification, provided to anyone connected to the website, about who is adding/removing a product to/from the cart.
Indeed, each time someone acts on the cart, a message will be broadcast to all of the connected browsers, and it will include the name of the user, the action (add or remove), and the product name.
The workflow will be as follows. When someone is connected to the website, a web socket will be opened between the browser and the server; a reference to that web socket will be kept at the server level, inside of an Actor.
As soon as an action is performed on the cart, a message with the username, action, and product name will be sent to the server through the web socket; the server will receive this message, transform it in to an alarm...