Search code examples
ajaxhtmlchatcometp2p

HTML5 p2p communication


I am required to build a web application to inject live subtitles on a live stream. Subtitles will be produced by an operator with a speech-recognition software (or by a typist), filling a textarea on a browser. The consumer will be an HTML5 video tag in a browser.

The rationale is quite simple, probably simpler than a web chat (it's a one-way communication).

This is my current implementation:

  • on the producer - when there is some new text - I call via AJAX a writer script on my server, which writes the text on a file.
  • on the consumer I continuously call via ajax (using "comet" polling) a reader script on the server, which gives me back the new text, which I inject over the video tag to render the subtitle.

This implementation works, but it looks quite convolute, I'm not quite satisfacted with it... Any suggestion for a "smarter" or cleaner architecture?


Solution

  • Sockets / nodejs. Sockets will open the connection to the browsers for you every time there is new data. No need to poll!

    Check this for example...