Jetty WebSocket api与标准JSR 356 API相比 [英] Jetty WebSocket api vs the standard 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 to Object转换的解码器
- 用于自动对象到Bin / Text转换的编码器
- Path Param handling(aka自动URI模板到方法参数映射)
但是,Jetty WebSocket API可以做JSR-356 API无法做到的事情。
However, the Jetty WebSocket API can do things the JSR-356 API cannot.
- WebSocketCreator lo用于任意创建WebSocket端点的gic,可以访问HttpServletRequest
- 更好地控制超时
- 更精细的缓冲区/内存配置
- 您可以管理WebSocket Extensions
- 支持基于Reg-ex的端点路径映射
- 访问原始帧事件
- WebSocket客户端支持HTTP代理(JSR-356独立客户端没有代理配置选项)
- WebSocket客户端支持更好的连接逻辑和超时
- WebSocket客户端支持SSL / TLS(JSR-356独立客户端没有SSL / TLS的配置选项)
- 从活动WebSocket会话访问两个InetAddress端点信息对象
- 从活动WebSocket会话对象访问UpgradeRequest
- 更好地支持无状态端点
- 读取事件支持暂停/恢复逻辑以允许应用程序一些基本的tcp背压/流量control
- 基于过滤器或基于Servlet的配置(JSR-356方法要求在所有其他servlet和过滤器处理之前进行升级)
- WebSocketCreator logic for arbitrary creation of the WebSocket endpoint, with access to the HttpServletRequest
- Better control of timeouts
- Finer buffer / memory configurations
- You can manage WebSocket Extensions
- Supports Reg-ex based Path mappings for endpoints
- Access to raw Frame events
- WebSocket client supports HTTP proxies (JSR-356 standalone client has no configuration options for proxies)
- WebSocket client supports better connect logic with timeouts
- WebSocket client supports SSL/TLS (JSR-356 standalone client has no configuration options for SSL/TLS)
- Access to the both InetAddress endpoint information from the active WebSocket Session object
- Access to UpgradeRequest from active WebSocket Session object
- Better support for stateless endpoints
- Read events support suspend/resume logic to allow application some basic tcp backpressure / flow control
- Filter based or Servlet based configuration (the JSR-356 approach requires upgrade to occur before all other servlet and filter processing)
希望这有帮助,如果您想了解更多详情,请使用 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屋!