保持服务器连接打开与定期请求更新

时间:2021-11-26 12:50:26

I am currently working on an online presentation tool. Consider the following scenario:

我目前正在开发一个在线演示工具。请考虑以下情形:

  • Someone gives a presentation
  • 有人发表了演讲
  • another person connects to watch said presentation
  • 另一个人连接观看所述演示文稿
  • >> I want to update the watcher's view when the presenter changes the slide
  • >>我想在演示者更改幻灯片时更新观察者的视图

what would be the better approach?

什么是更好的方法?

  1. forcing the connection to stay open to send updates onSlideChange
  2. 强制连接保持打开以发送更新onSlideChange
  3. periodically (every second or so) letting the client request an update
  4. 定期(每隔一秒左右)让客户请求更新
  5. something else I am not aware of
  6. 我不知道的其他事情

Thanks!

谢谢!

1 个解决方案

#1


0  

I would suggest using websockets for this, however your websocket would have to be a separate application running through a higher level PORT on your server.

我建议使用websockets,但是你的websocket必须是一个单独的应用程序,通过服务器上的更高级别的PORT运行。

There are a few PHP websocket tools out there, have a look at http://socketo.me/ (as this was the first result on google!) or you could write one with PHPs Socket methods, but you will need to do some reading on Websocket standards and handshake decryption.

有几个PHP websocket工具,看看http://socketo.me/(因为这是google上的第一个结果!)或者你可以用PHPs Socket方法编写一个,但是你需要做一些阅读Websocket标准和握手解密。

#1


0  

I would suggest using websockets for this, however your websocket would have to be a separate application running through a higher level PORT on your server.

我建议使用websockets,但是你的websocket必须是一个单独的应用程序,通过服务器上的更高级别的PORT运行。

There are a few PHP websocket tools out there, have a look at http://socketo.me/ (as this was the first result on google!) or you could write one with PHPs Socket methods, but you will need to do some reading on Websocket standards and handshake decryption.

有几个PHP websocket工具,看看http://socketo.me/(因为这是google上的第一个结果!)或者你可以用PHPs Socket方法编写一个,但是你需要做一些阅读Websocket标准和握手解密。