Multi-user editing on a complex page using server click

I am using the Zend Framework for an application called Pricetag , and we are thinking of adding support for multi-user editing. Basically, the idea is to take each of 4 steps in order to be able to share what you are editing with other online users (just like Pivotal Tracker or Trello ).

This is a screenshot of the most complex (programmatically speaking) of the four pages that we have:

Pricetag Step 2 screenshot

Internal HTML is not important (but hey, you can register as a free user if you want to check it out), basically some inputs and the ability to add / remove these blocks ("results" and "tasks") with JavaScript.

I assume that I need a way for the server to notify each online client of changes on the page. I already make a request every time you change something (the white block on the right is updated every time you do this), but I don’t know exactly how other users will get this information.

Polling the server every 5 seconds or so seems very wrong. The site uses PHP, is this enough? Should I interact with a separate script on the server? Is there an already created Zend Framework module that I am missing, although I first asked Google?

+6
source share
4 answers

Try this comet server - http://dklab.ru/lib/dklab_realplexor/

It has PHP and javascript API, see the example for the sandbox - http://rutwit.ru/realplexor/demo

The comet server written in perl, the source and tarball files are available here - http://github.com/DmitryKoterov/dklab_realplexor/tarball/master

see other technologies -

Tornado web server . The web server imposed on Python, not only on the comet server, is an environment where you can create a comet server.

NginxHttpPushModule : A simple module for the nginx web server that adds Comet support.

CometD : Scalable HTTP-based routing using Ajax Push. Subscription to many channels is supported.

APE : this is more of a foundation for building comet systems than a finished product.

Stardust is a simple COMET server in perl (the author’s comment is “the simplest COMET server I could imagine”).

Orbited : emulating TCP sockets in JavaScript.

+6
source

Take a look at the socket.io library. It uses many methods to asynchronously notify clients.

+2
source

We experimented with using Comet for a chat client variety once. The basic premise is that you open the connection (probably an AJAX request) to the web server and keep it open until

  • Timeout expires (say 30 seconds)
  • or there is some state of the application that requires sending data to the client.

At this point, the request is returned. If there is a payload, apply all that needs to be done, then repeat the request, which will begin the process.

The only serious drawback that we encountered was that many connections were open (just sitting there, waiting for an answer), we quickly exhausted the number of threads in Apache, and future ones were stopped. At this point, we refused the exercise (for other reasons), so we never considered possible corrections.

Another problem was to separate separate PHP threads in order to talk to each other, which is also not easy. As far as I remember, we ended up using something built on sockets, and each thread could talk to the other, given the unique identifier (I myself did not work on this bit, so I'm not sure if this is absolutely correct). In your case, you can check the runtime in a DB or file, and then return when the change occurs.

I would suggest that everything will evolve from the time we tried it (this was a few years ago), but I suspect that the general idea still remains, and the libraries used this.

+1
source

Many of the push libraries actually return to server polls every few seconds.

We implemented a chat script to open the connection, but this led to problems with some clients and their firewalls. I will not do this anymore. If you keep the connection open, do not use HTTP on port 80.

This is also a question of what the PHP script does. Running a database query every few seconds for each client can be slow. We got around this by writing a static HTML file that ajax polled every few seconds for changes. In most cases, the server did not report an error (301?). This is a small server load and is often discussed in more detail in HTTP Keep-alive. If you still think you cannot load your server, you can also rent web space to host static files.

0
source

Source: https://habr.com/ru/post/901573/


All Articles