`onMessage` means when a new message (sent or received) is created. We dont need to add redundant code if at the end is the same function (we would have 2 functions calling to other, without any modification). Now code is generic, and a new message (sent or received) needs some common actions to be executed. That's why the change.