Exercise 2: Discussion
The difference is obvious this time: the message keeps turning back and the simulation never stops... In the graphical output, no difference can be seen, as the color stays red. You would need to stop the simulation manually.
Try also something else here: bring back the "delete(msg);" line at the very end of the handleMessage() method. Re-run and observe. The simulation crashes and an error message is shown, which helps you understand what you did wrong. In this case, you are not allowed to send the message to the kernel and then delete it - it is not "yours" anymore. Many of the errors we all make in OMNeT++ are repetitive: we forget to correctly define modules, we delete messages from the kernel's queue, etc. For many of these cases, OMNeT++ checks for us and tells us straight away what happened and what to do. Thus:
READ the error messages! 😝
In the next few pages, we will see how to toggle the color every time.