netty-socketio 与 Tomcat8 的集成 [英] netty-socketio integration with Tomcat8

查看:46
本文介绍了netty-socketio 与 Tomcat8 的集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在考虑将 socket.io 用于用 Java 编写的实时网络应用程序.从我看来,socket.io 服务器主要是为 Node.js 开发的,并且在 Java 中有它的端口.似乎 netty-socketio 是一个稳定的解决方案.

I'm thinking of using socket.io for a real time web app written in Java. From what I see socket.io server is mainly developed for Node.js and there are ports for it in Java. Seems netty-socketio is a stable solution.

我不知道是否可以将它嵌入到我在 Tomcat8 上运行的应用程序中的 WAR 文件中并且像这样运行它没有问题.

I can't figure out though if I can embed it in a WAR file within my application running on Tomcat8 and have no issue running it like that.

有没有人把这个集成到 Tomcat8 的 WAR 文件中?

Has anyone integrated this within a WAR file in Tomcat8?

推荐答案

就像馅饼一样简单,只需创建 com.corundumstudio.socketio.SocketIOServer.示例:

It's as easy as pie, just create com.corundumstudio.socketio.SocketIOServer. Example:

在你的 tomcat Servlet.init 方法中输入:

In your tomcat Servlet.init method type follow:

Configuration config = new Configuration();
config.setHostname("localhost");
config.setPort(81);

SocketIOServer server = new SocketIOServer(config);
server.start();

这篇关于netty-socketio 与 Tomcat8 的集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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