简体   繁体   中英

What to use for Websocket/XML communikation for Java?

i need a websocket based communication with XML data between 2 machines. The client side seems to be quite easy using TooTallNates small client. But what to use for server side? I checked Jetty and Glassfisch, but both seem to be overkill for what i need. I need to integrate a (small) websocket server into an existing Java application. This application controls a machine. The machine produces data (status information and the like). There will be several clients which should read these information. The machine has only 2 types of information: a full data collection, which should be sent after connecting and on request, and some incremental data set, sent based on change events, independent of any request, sent to all clients. And that's all. No need for any java server pages, no need for html, no need for JSon. The XML format might be SOAP or XML-RPC, but it may well be any other xml format. The data has just to be transferred in a platform-independent, compatible way from A to B. So any XML format seems to be appropriate. And websocket seems to be some kind of standard. There will be 3rd party applications which will connect, too. So using this standard seems to be adequate.

I do not need a full-blown, standalone server. I need a java class to be integrated into an existing application for easy transferring data between 2 or more machines. Can anyone recommend anything?

Instead of using full blown HTTP server with Websocket support like Jetty or Tomcat you can write your own Websocket server with the help of Netty.

Netty is a NIO client server framework which enables quick and easy development of network applications such as protocol servers and clients. It greatly simplifies and streamlines network programming such as TCP and UDP socket server. http://netty.io/

Here it is a small example of using Netty to build game server with Websocket I found on web http://www.gamedevcraft.com/2016/01/multiplayer-card-game-using_22.html

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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