now actually forks another worker thread for sending messages to the connected user.

6 Cleanups and final code

Screenshot :)

There are two major problems left in the code. First, the code has a memory leak, because the original channel is never read by anyone. This can be fixed by adding another thread just for that purpose.

Secondly, closing connections is not handled gracefully at all. This requires exception handling.

The code below fixes the first issue and mostly fixes the second one, and adds a few cosmetic improvements: