I am new in spring boot and web services. I am supposed to create a websocket in spring boot so that it could transfer XML files from server to its connected clients. As I understood, the server only bypasses the file/messages to clients that it receives from one client. It means the server is notified to send something to clients, only if there is a message in their topic or channel. Is that true? If yes, how I could upload a file, for example from my local machine, to the websocket server and then broadcast it to my clients?
I have implemented this scenario in nodejs in a way that server reads a file and emits an event, but in spring boot, the handler function is connected to the common channel and I wonder how I could send data to the channel/topic from an external resource, not from the clients.
Here is a sample controller code from spring website tutorials:
public class GreetingController
{
@MessageMapping("/hello")
@SendTo("/topic/greetings")
public Greeting greeting(HelloMessage message) throws Exception
{
Thread.sleep(1000); // simulated delay
return new Greeting("Hello, " + HtmlUtils.htmlEscape(message.getName()) + "!");
}
}
I appreciate if you can explain it with a simple code of spring boot handler function to make it clear for me.
Thank you so much in advance.