使用Websocket控制数据流-JavaScript编程系列



从2011年开始,创建了新的TCP通信,以允许从客户端到服务器的双向数据。自从首次引入以来,websocket已经在现代浏览器中得到了很好的支持,在生产系统中也越来越普遍。

在本教程中,我们将介绍websocket的客户端和服务器实现,以创建功能齐全的通信渠道。

W3C规范:https://www.w3.org/TR/2011/WD-websockets-20110929/

通过“我可以使用”获得浏览器支持:http://caniuse.com/websockets/embed/

Websocket上的MDN文档:https://developer.mozilla.org/en-US/docs/Web/API/WebSocket

Github回购代码:https://github.com/ignoreintuition/websocket

3 comments
  1. If you have several distinct functionalities on your frontend like a video player and a real-time chat, how do you differentiate the messages coming from the backend to route the data to the correct component? In this case, do you create multiple sockets i.e. one per component?

Comments are closed.