Slim 4 Websocket integration

Recently I’ve chalenged myself with this issue:
Slim 3 framework and Twig with Ajax GET and POST for Home Page Chat problem?

I was hoping, if I dig deep enough it would be possible to find some nice and simple integration solution for ratchet with Slim 4.
Yes it can be done, but I did not succeed, because the result I achieved, was neither nice nor simple considering engaged resources and amount of code necessary to add to an application just a simple chat functionality. In my humble opinion php is still not ready for a client - server bidirectional interaction.

I did not want to relay totally on nodejs, so I started searching for some hybrid solutions, meaning the simplest possible, just to make websocket integration smooth and simple for an ordinary developer. I found and I think I succeed this time.

Please take a look at the result and maybe give some feedback: