From the course: Building Real-Time Web Apps with Spring Boot and WebSockets

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Sending messages to the server

Sending messages to the server

From the course: Building Real-Time Web Apps with Spring Boot and WebSockets

Start my 1-month free trial

Sending messages to the server

- So we just saw what it was like to establish a connection and start subscribing to the topics that we care about in our chat app client. Now for the most exciting part, sending messages. For this exercise, we're gonna share exactly what code you need to have to make sure that messages are sent to the server, and then that the server can then broadcast those messages back to all of the chat participants. So let's take a look at some JavaScript. Again for this exercise, we're gonna open up our our app.js file, which is located in our src/main/resources tree in the static subdirectory. I'm gonna double click on the editor so we can maximize, get a little more space, and much like our last subscription for topic guest names, the code here is pretty much the same, the only difference being a different topic name. So for our guests to chat with each other, we've set up a topic called guestchats. And I already have a message ready to go to implement what should happen when guests chat with…

Contents