Posted by instant messenger: http://rsdn.ru/forum/flame.comp/6042249.1 It works on ordinary HTTP requests. Now I try to understand how it should work in the correct version.
I got an understanding of what to do with a TCP connection, the server authorizes it, signs up for updates and sends data to the socket when it appears.
I understand web-based websites and begin to understand that you cannot make any subscriptions for them. That is, it is the same HTTP, but without breaking the connection.
So how should a messaging system be built to be more optimal?
- In the mode of responding to client requests, plus send notifications about new events.
- In the mode of responding to client requests, but the client must constantly send a request for updating data.
The first option seems more optimal, but it will require more cunning logic. Is it implemented in php? The second option is simpler, but periodic requests, say every 2 seconds, this does not seem to be the best solution.