Echo Chat Application
Understand core concepts of WebSocket using an echo chat application.
We'll cover the following
WebSocket on AWS
The AWS API Gateway enables simple implementation of Websocket API. When configuring a WebSocket API, we don’t have to worry about the server-side protocol. Instead, we can create a new entity when we’re ready to use it.
A WebSocket API configuration requires integrations for specific events or routes in the incoming request.
On Connect: When a new connection is established.
On Disconnect: When an existing connection is terminated.
Additional custom action (optional): We can specify custom actions in the API.
Default action (optional): Invoked when the action in the incoming message isn’t configured explicitly.
We can provide individual integrations for these routes when configuring a WebSocket API. Let’s look at a small example of how a WebSocket is implemented with the API Gateway.
Chat application
Online chat is a classic use case for WebSockets, where the server pushes chat messages back to the client. WebSocket API is the best way to implement such applications. Let’s see how we can implement this in the code. We can start with a simple echo chat application. This application simply echoes the message back to the same client.
Create a free account to view this lesson.
By signing up, you agree to Educative's Terms of Service and Privacy Policy