所以我想建立一个聊天应用程序,将允许视频,音频和文本。我花了一些时间研究Websockets和WebRTC来决定使用哪个。既然有很多WebRTC的视频和音频应用程序,这听起来是一个合理的选择,但我还应该考虑其他事情吗?
欢迎分享你的想法。
喜欢的东西:
由于WebRTC是新的,它只在一些浏览器上可用,而WebSockets似乎在更多的浏览器中可用。
可伸缩性——Websockets使用服务器进行会话,WebRTC似乎是p2p的。
多路/多聊天室-用于谷歌+ Hangouts,我仍然在查看如何实现的演示应用程序。
服务器- Websockets需要RedisSessionStore或RabbitMQ来跨多台机器扩展。
尚:
Ratified IETF standard (6455) with support across all modern browsers and even legacy browsers using web-socket-js polyfill.
Uses HTTP compatible handshake and default ports making it much easier to use with existing firewall, proxy and web server infrastructure.
Much simpler browser API. Basically one constructor with a couple of callbacks.
Client/browser to server only.
Only supports reliable, in-order transport because it is built On TCP. This means packet drops can delay all subsequent packets.
WebRTC:
Just beginning to be supported by Chrome and Firefox. MS has proposed an incompatible variant. The DataChannel component is not yet compatible between Firefox and Chrome.
WebRTC is browser to browser in ideal circumstances but even then almost always requires a signaling server to setup the connections. The most common signaling server solutions right now use WebSockets.
Transport layer is configurable with application able to choose if connection is in-order and/or reliable.
Complex and multilayered browser API. There are JS libs to provide a simpler API but these are young and rapidly changing (just like WebRTC itself).