This is not a good idea. HTTP is a request-response protocol so if you
want server-client communication to be bi-directional you will need to look
into websockets or something similar. There are also things like "long
polling" and "heart beating"
If you want an event loop try something like servlets in apache
You will grapple for hours with issues because of your design.
Make sure you know an overview of the tech stack you are working with