JavaFX desktop application - socket communication

2020-06-22 01:28发布

问题:

I want to develop a simple desktop application with real-time data refresh (on multiple clients). Is it possible to develop an application such as this that communicates with web service over sockets?

Here is what I wish to know:

  • What are the basic steps to do this?
  • Is it possible to use Spring WebSocket to do this?
  • Any code examples?

回答1:

Yes, you can definitely use Spring WebSocket for real-time data refresh on multiple clients.
Of course, both client and server should support the WebSocket protocol.
For quick start, take a look at the followed:
http://spring.io/guides/gs/messaging-stomp-websocket/
http://start.spring.io/

For full reference of both server and client options take a look here: http://docs.spring.io/spring/docs/current/spring-framework-reference/html/websocket.html
In particular, it provides a short discussion on when to use it: http://docs.spring.io/spring/docs/current/spring-framework-reference/html/websocket.html#websocket-intro-when-to-use