Reputation: 534
We are having existing Web application in Spring MVC. We are using Tomcat server. Also we have mobile app [Androis and iOs] for the same which is using spring based rest services. Now, we want to integrate chat functionality to both mobile and web application. I came across Socket.io and Node.js, which seems good. But, I am not much aware of these two frameworks. Then I came to know about Spring WebSocket.
Few Questions :
Which way is better to implement chat for existing spring based web and mobile applications ? - Spring Websocket / Socket.io - Node.js
If we are going with Socket.io and Node.js, then how could I configure the node.js to listen to my existing tomcat server port ? Or I need to use separate port for client server communication for chat functionality. [Because I tried to use same port, it was giving Error: listen EADDRINUSE :::9090]
Any example would be the great help.
TIA.
Upvotes: 0
Views: 662
Reputation: 5801
Here is the sample application that sends messages back and forth,
Socket.io is used on client side to subscribe to a Topic of the server side.
Similarly you can use Sock.js with stomp client at client side and Spring on server side which provides an easy configuration with STOMP and also message handler annotation such as
@MessageMapping annotation which ensures that if a message is sent to destination mapping say "/hello" then the method associated with it should be called.
@SendTo annotation which is used to specify the value on which the returned message will be broadcast.
#Example stomp with spring for sending messages.
Upvotes: 1