From the course: WebSocket Programming with Java EE

Unlock the full course today

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

✓ Solution: Ping/pong endpoint

✓ Solution: Ping/pong endpoint

From the course: WebSocket Programming with Java EE

Start my 1-month free trial

✓ Solution: Ping/pong endpoint

- [Narrator] So, how do you get on with this task? Well, let's have a look at my solution. To start, I created a client and a server. I pitched a PongServer and a PingClient and the corresponding endpoints. PongServerEndpoint and PingClientEndpoint. The PingClient is responsible for sending the Ping and the Pong messages. So, in part one it sends a Pong message by calling their sendPong method and the server handles the Pong message in the Pong message handler. Then the Ping client sends a Ping message, using the sendPing method, which is automatically responded to by the server with a Pong message. And that message is picked up by the Pong message handler in the client endpoint. The message payload is echoed back to the client. Okay, so let's execute this code and see it in action. First of all, I execute the server. Then, the client. The first thing the client will do is to send a Pong message that the server will pick up and the client is sent a Pong message and you can see that…

Contents