前端同步
2016-08-26 11:54:03 0 举报
前端同步是一种在多个客户端之间保持数据一致性的技术。它通过实时更新数据,确保所有客户端都能看到最新的信息。这种技术通常用于在线协作工具、聊天应用和多人游戏等场景。前端同步可以通过轮询、WebSockets或Server-Sent Events等方法实现。轮询是客户端定期向服务器发送请求,以获取最新数据。WebSockets是一种双向通信协议,允许服务器主动向客户端推送数据。Server-Sent Events也是一种单向通信协议,允许服务器向客户端推送数据。前端同步可以提高用户体验,但也可能增加服务器负载。因此,在选择前端同步方法时,需要权衡性能和用户体验。
作者其他创作
大纲/内容
type=sync event ?
{ type: \"sync event\
http://example.com/page2
写入localStorage:sync=event.data
发送给parent:window.parent.postMessage(event.data)
收到storage消息
iframe收到:event.data
回到父页面
yes
发送给iframe:iframe.postMessage()
调用 callback(”hell world“)
YES
http://example.com/page1
父页面
iframe内
触发 window.sync,带参数”hell world“
dispatchMessage(\"hello world\")
http://test.com/
0 条评论
下一页