简体   繁体   English

是否可以“流式传输”本地控制的 Vue.js 页面,因此所有设备共享相同的 state?

[英]Is it possible to “stream” locally controled Vue.js page, so all the devices share the same state?

I'm making a simple teleprompter app, and the idea is to control it through a local PC but to have the same view/Vuex state while accessing the page from my tablet.我正在制作一个简单的提词器应用程序,其想法是通过本地 PC 控制它,但在从我的平板电脑访问页面时具有相同的视图/Vuex state。 So, same page, same state, multiple devices.因此,相同的页面,相同的 state,多个设备。

Do I understand correctly that the only way is to duplicate all the mutation requests to the server, save them to the DB, monitor changes in the DB, and replicate them on the "client" device?我是否正确理解唯一的方法是将所有突变请求复制到服务器,将它们保存到数据库,监视数据库中的更改,并将它们复制到“客户端”设备上?

I could always share the screen image as a video, so the question is theoretical, and any ideas would do:)我总是可以将屏幕图像作为视频分享,所以这个问题是理论上的,任何想法都可以:)

PS Similar-looking problem: Recommended strategy to sync vuex state with server . PS 类似的问题: 建议将 vuex state 与 server 同步的策略

Sure it's possible.当然有可能。 Here are 3 bold approaches:这里有3种大胆的方法:

  1. Server as a storage.服务器作为存储。 I assume both devices are logged in under the same user-id.我假设两个设备都使用相同的用户 ID 登录。 Each device has a socket connection to the server.每个设备都有一个到服务器的套接字连接。 Whenever one device changes its state it send it to the server, then the server relay this state to all connected devices.每当一台设备更改其 state 时,它会将其发送到服务器,然后服务器将此 state 中继到所有连接的设备。
  2. Server as a proxy.服务器作为代理。 Both devices create a direct socket connection using a server.两个设备都使用服务器创建直接套接字连接。 One client sends all its changes directly to another.一个客户端将其所有更改直接发送给另一个客户端。
  3. Direct P2P via webRTC.通过 webRTC 直接 P2P。 Two clients establish a direct client-to-client connection.两个客户端建立直接的客户端到客户端连接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM