0

I am making a platform where users submit a message to a board and everyone sees that message (almost instantly). Using AJAX, that message is sent to the Flask server and saved in a database. How do I ensure that other users get this message?

The only solution I have thought of is asking the server for an updated message list every T seconds (for example, run an AJAX call every 5 seconds). Is this the best way with the technology I am using? Anything more optimal?

shurup
  • 751
  • 10
  • 33
  • Look into websockets. – ceejayoz Oct 26 '19 at 01:36
  • I believe what you are thinking is called "long-polling". That is a valid way to do it. But it would probably be more efficient to use websockets. There is a really nice introduction to websockets here: https://www.youtube.com/watch?v=PjiXkJ6P9pQ You may also want to check out this stackoverflow answer: https://stackoverflow.com/a/12855533/7228779 – selmanbey Oct 26 '19 at 01:49

0 Answers0