-http2的含义是什么,而websockets则不提供客户使用的API?
https://stackoverflow.com/a/a/42465368/462608
Websockets仍然可以在哪里?最大的是服务器 - >浏览器推出的二进制数据。 http/2确实允许服务器 - >浏览器按下二进制数据,但在浏览器js中不会暴露出来。对于按下音频和视频帧等应用程序,这是使用Websocket的原因。
当他们说推动二进制数据未在浏览器JS中暴露的二进制数据时,这是什么意思?我要求一些例子来帮助我理解这一点。
https://stackoverflow.com/a/47108355
,因此http2推动实际上是您的浏览器和服务器之间的某些内容,而WebSocket确实会揭示客户端(JavaScript,如果在浏览器上运行)和应用程序代码(在服务器上运行)可以使用的API,以实时传输实时传输实时传输数据。
我请求一些示例,以使我了解http2 push的含义实际上是您的浏览器和服务器
和WebSockets(socket.io)具有API之间的含义,客户端可以使用。
这意味着什么?
https://stackoverflow.com/a/42465368/462608
Where might websockets still have a place? The big one is server->browser pushed binary data. HTTP/2 does allow server->browser pushed binary data, but it isn't exposed in browser JS. For applications like pushing audio and video frames, this is a reason to use websockets.
What does it mean when they say that that pushed binary data isn't exposed in browser JS? I request some example to help me understand this.
https://stackoverflow.com/a/47108355
And so HTTP2 push is really something between your browser and server, while Websockets really expose the APIs that can be used by both client (javascript, if its running on browser) and application code (running on server) for transferring real time data.
I request some examples to make me understand the meaning of HTTP2 push is really something between your browser and server
and Websockets (socket.io) has API which can be used by clients.
What does all this mean?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在这里,我们谈论的是双向(bidi)消息传递 server 和 client 。在您的情况/问题中,客户是浏览器。
要了解发生了什么,我们应该了解什么是HTTP/2和Websocket。
发送
send 将消息推向服务器的方法。反之亦然,服务器可以使用相同的流/频道将消息推向浏览器,因此现在我们可以尝试回答问题
这意味着,如果服务器对您的请求“推”其他数据,则您将在JavaScript中不知道它。
http/2“按”'其他数据可以由浏览器使用来实现浏览器缓存。您可以阅读有关它的信息在这里。
中的属性来获取服务器数据的任何推动
使用WebSocket,您可以使用WebSocket
onMessage
javaScript 但是 !浏览器提供允许您使用http/2流但以仅阅读模式使用。这意味着您可以订阅服务器事件,但无法将事件从客户端发送到服务器。因此,它仅在一个方向(从服务器 - >到客户端)上工作。另外,如果服务器不支持http/1 http/1.x上的http/2浏览器后备Here, we are talking about bidirectional(bidi) message passing between server and client. In your case/question, client is a Browser.
To understand what's going on, we should understand what are HTTP/2 and WebSocket.
send
method to push a message to the server. And vice versa, the server can push a message to the browser using the same stream/channelSo now we can try to answer on questions
It means that if server "Push" additional data on your request you will not know about it in JavaScript.
HTTP/2 "Push"'ed additional data can be used by Browser to fulfil the Browser cache. You can read about it here.
With WebSocket you can get any pushed by server data using WebSocket
onmessage
property in JavaScriptBUT! Browser provide Server Sent Event(SSE) functionality which allow you to use HTTP/2 stream but in read-only mode. It means that you can subscribe to server events, but could not send events from the client to the server. So it works only in one direction (from server -> to client). Also, if server doesn't support HTTP/2 browser fallback on HTTP/1.x for SSE