WebSocket+STOMP+SockJS

WebSocket

https://www.w3.org/TR/websockets/

The WebSocket protocol defines two types of messages, text and binary, but their content is undefined. It’s expected that the client and server may agree on using a sub-protocol (i.e. a higher-level protocol) to define message semantics. While the use of a sub-protocol with WebSocket is completely optional either way client and server will need to agree on some kind of protocol to help interpret messages.

WebSocket sub-protocols

the WebSocket RFC defines the use of sub-protocols
https://tools.ietf.org/html/rfc6455#section-1.9

STOMP

STOMP is a simple text-orientated messaging protocol.
STOMP is widely supported and well suited for use over WebSocket and over the web.

STOMP是一种简单的消息协议,非常合适用作WebSocket的子协议
http://jmesnil.net/stomp-websocket/doc/

SockJS

https://github.com/sockjs/sockjs-client

使用SockJS作为客户端,当浏览器不支持websocket时,会使用长轮询等方式。

The SockJS client begins by sending “GET /info” to obtain basic information from the server. After that it must decide what transport to use. If possible WebSocket is used. If not, in most browsers there is at least one HTTP streaming option and if not then HTTP (long) polling is used.

Chrome 可以在引用sockjs文件前禁用websocket,从而看到长轮询的效果。

window.WebSocket = null;
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值