Hi. I’m trying to manage a collection of WebSocket connections to my server so that I can notify them all when users connect/disconnect/send messages. I can do this with a simple struct like this
struct IdentifiedWebSocket: Identifiable {
var id: UUID = UUID()
var websocket: WebSocket
}
and a dictionary of collections like this
static var chatClients: [GroupID: [IdentifiedWebSocket]] = [:]
As the book mentioned here that this is not scalable, I’ve been looking into Redis. So I set up Redis, but I’m at a loss on how to encode the pertinent WebSocket information. I’m new to WebSockets and I’m going to continue to read the source code and docs, but I was wondering if there were any good tips for what I need to store so that I can encode to and decode the collection of groups of clients from Redis.
Or if there is a different approach entirely I should take, I’m open to that as well. Thank you in advance!