8

我需要使用 dropwizard 项目实现 websocket。但是我找不到任何与之相关的文件。任何人都可以指出相同的资源。

4

3 回答 3

8

我一直在处理同样的问题,并想分享我的解决方案: http ://cvwjensen.wordpress.com/2014/08/02/websockets-in-dropwizard/

我使用 Atmosphere 框架,该解决方案默认使用 websockets,但如果需要,可以降级为长轮询。

这应该足以让你开始......

于 2014-08-02T08:05:11.663 回答
1

I'm looking to do this too. This is the best information I've found so far:

Supposedly one of the most popular websocket frameworks out there works well with Jersey (Jersey is bundled with Dropwizard). You can find more about it here: https://github.com/Atmosphere/atmosphere

Also, someone has published a repository integrating the two of them together: https://github.com/mgutz/dropwizard-atmosphere/

于 2013-05-01T05:18:42.427 回答
1

我通过包含 CometD 将 websockets 实现到 Dropwizard 项目中。

CometD 包含一个用于处理 WS 请求的 servlet,Dropwizard 公开环境以允许您注册任意 servlet。

我的应用程序(Groovy)的一小段摘录:

    environment.addServlet(new Initializer(httpClient, amqpConsumer), "/_initializer")
            .setInitOrder(2)

    environment.addServlet(AnnotationCometdServlet, "/cometd/*")
            .addInitParams([
            transports: 'org.cometd.websocket.server.WebSocketTransport',
            services: EventService.getCanonicalName(),
            jsonContext: 'org.cometd.server.JacksonJSONContextServer',
            maxSessionsPerBrowser: serviceConfiguration.maxBrowserSessions.toString(),
            maxInterval: '7200',
            logLevel: "2"
    ]).setInitOrder(1)

如 CometD 教程中所示,初始化器 servlet 使事情变得简单。

于 2013-05-27T00:00:31.997 回答