简体   繁体   English

netty-socketio与Tomcat8的集成

[英]netty-socketio integration with Tomcat8

I'm thinking of using socket.io for a real time web app written in Java. 我正在考虑将socket.io用于使用Java编写的实时Web应用程序。 From what I see socket.io server is mainly developed for Node.js and there are ports for it in Java. 从我看来,socket.io服务器主要是为Node.js开发的,并且在Java中有用于它的端口。 Seems netty-socketio is a stable solution. netty-socketio似乎是一个稳定的解决方案。

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? 是否有人将其集成到Tomcat8的WAR文件中?

It's as easy as pie, just create com.corundumstudio.socketio.SocketIOServer . 就像馅饼一样简单,只需创建com.corundumstudio.socketio.SocketIOServer Example: 例:

In your tomcat Servlet.init method type follow: 在您的tomcat Servlet.init方法中,输入:

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM