Skip to content
This repository was archived by the owner on Nov 14, 2024. It is now read-only.

Commit 4a2b643

Browse files
committed
improved introduction and map function
1 parent d13668c commit 4a2b643

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

_posts/2024-04-20-websockets2.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ toc_label: "In this article"
1212
_by [Herbert Kateu](https://github.com/hkateu)_
1313

1414
## 1. Introduction
15-
This article is a follow-up from the [websocket](https://blog.rockthejvm.com/websockets-in-http4s/) article that was published previously, in this iteration we'll be integrating Redis to keep track of the users and rooms and we'll also be persisting messages in Postgres so that new users can have access to previous conversations. Finally, We'll get rid of `chatState` and create a new protocol that interacts with Postgres and Redis.
15+
This article is a follow-up to the [websocket](https://blog.rockthejvm.com/websockets-in-http4s/) article that was published previously. To recap, we created an in-memory chat application using WebSockets with the help of the Http4s library. The chat application had a variety of features implemented through commands directly in the chat window such as the ability to create users, create chat rooms, and switch between chat rooms.
16+
17+
In this iteration, we'll be integrating Redis to keep track of the users and rooms and we'll also be persisting messages in Postgres so that new users can have access to previous conversations. Finally, We'll get rid of `chatState` and create a new protocol that interacts with Postgres and Redis.
18+
19+
Since this tutorial builds on the previous article, to follow along, we'll need to clone that [GitHub repo](https://github.com/hkateu/WebsocketChatApp) where we'll be making the necessary updates to build this new version.
1620

1721
## 2. Setting Up
1822
We'll be using skunk and redis4Cats in our application so let's add them to our `build.sbt` file.
@@ -1275,14 +1279,11 @@ new ChatProtocol[F] {
12751279
case Some(roomid) =>
12761280
redisP.listUserIds(roomid).flatMap { u =>
12771281
redisP.getSelectedUsers(u.toList.head, u.toList.tail).map {
1278-
maybelist =>
1279-
maybelist match {
1280-
case Some(lu) =>
1281-
lu.map(_.name.name)
1282-
.sorted
1283-
.mkString("Room Members:\n\t", "\n\t", "")
1284-
case None => ""
1285-
}
1282+
case Some(lu) =>
1283+
lu.map(_.name.name)
1284+
.sorted
1285+
.mkString("Room Members:\n\t", "\n\t", "")
1286+
case None => ""
12861287
}
12871288
}
12881289
case None => "You are not currently in a room".pure[F]

0 commit comments

Comments
 (0)