Jetty WebSocket API 与标准 JSR 356 API [英] Jetty WebSocket api vs the standard JSR 356 API

查看:45
本文介绍了Jetty WebSocket API 与标准 JSR 356 API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Jetty 9 支持 两者它自己的 Jetty Websocket API 以及标准 JSR 356 API,我认为是历史原因(Jetty 的 API 先于最终的 JSR 356).

Jetty 9 supports both it's own Jetty Websocket API as well as the standard JSR 356 API, for what I assume are historical reasons (Jetty's API precedes the final JSR 356).

我查看了这两个 API 的基本文档以及一些示例.这两个 API 看起来都相当完整且相当相似.但是,我需要为我正在编写的新项目选择一个,并且我希望避免使用将来可能会被弃用或功能不那么丰富的 API.

I've looked over the basic documentation of both APIs, as well as some examples. Both APIs seem fairly complete and rather similar. However, I need to choose one over the other for a new project I'm writing, and I'd like to avoid using an API that might be deprecated in the future or might turn out to be less feature-rich.

那么,除了一个是标准化的这一显而易见的事实之外,两者之间还有什么重要的区别吗?

So are there any important differences between the two except for the obvious fact that one is standardized?

推荐答案

Jetty 上两者的实现者 :)

Implementor of both on Jetty here :)

首先是 Jetty WebSocket API,而 JSR-356 API 则建立在它之上.

The Jetty WebSocket API came first, and the JSR-356 API is built on top of it.

JSR-356 API 做了一些 Jetty WebSocket API 没有的事情,比如

The JSR-356 API does a few things that the Jetty WebSocket API does not, such as

  • 用于自动 Bin/Text 到 Object 转换的解码器
  • 用于自动将对象转换为 Bin/Text 的编码器
  • 路径参数处理(又名自动 URI 模板到方法参数映射)

然而,Jetty WebSocket API 可以做 JSR-356 API 不能做的事情.

However, the Jetty WebSocket API can do things the JSR-356 API cannot.

  • 用于任意创建 WebSocket 端点的 WebSocketCreator 逻辑,可以访问 HttpServletRequest
  • 更好地控制超时
  • 更精细的缓冲区/内存配置
  • 您可以管理 WebSocket 扩展
  • 支持端点的基于 Reg-ex 的路径映射
  • 访问原始帧事件
  • WebSocket 客户端支持 HTTP 代理(JSR-356 独立客户端没有代理配置选项)
  • WebSocket 客户端通过超时支持更好的连接逻辑
  • WebSocket 客户端支持 SSL/TLS(JSR-356 独立客户端没有 SSL/TLS 的配置选项)
  • 从活动的 WebSocket 会话对象访问两个 InetAddress 端点信息
  • 从活动的 WebSocket 会话对象访问 UpgradeRequest
  • 更好地支持无状态端点
  • 读取事件支持挂起/恢复逻辑,以允许应用程序进行一些基本的 tcp 背压/流量控制
  • 基于过滤器或基于 Servlet 的配置(JSR-356 方法要求在所有其他 servlet 和过滤器处理之前进行升级)

希望这会有所帮助,如果您想了解更多详细信息,请使用 jetty-users 邮件列表,因为这种问题真的不适合 stackoverflow.

Hope this helps, if you want more details, please use the jetty-users mailing list, as this sort of question is really inappropriate for stackoverflow.

这篇关于Jetty WebSocket API 与标准 JSR 356 API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆