- Goal is to find chat partner, a random partner.
- There are n+ chat servers.
- Chat servers talk to each other via pub/sub over redis.
- Each chat server has n* websocket connections connected to it.
- Connected users may request to be connected to be a random user other than themselves.
I'm having trouble developing a handshake protocol where servers can communicate with each other and find a partner for their respective users.
Look at (???) that's where things break down. I could add more events but that's just delaying the problem, I think.
//flow
u -> chatRequest
n <- chatRequest
n <- chatRequest
n <- chatRequest
n -> chatOffer1
n -> chatOffer2
n x
u <- chatOffer1 (in chat)
u -> acceptOffer1
n <- acceptOffer1 (in chat)
u <- chatOffer2 (do nothing) //everything is fine
//flow
x -> chatRequestX
y -> chatRequestY
a <- chatRequestX
a <- chatRequestY
b <- chatRequestX
b <- chatRequestY
c <- chatRequestX
c <- chatRequestY
a -> chatOfferXA
a -> chatOfferYA
b -> chatOfferXB
b -> chatOfferYB
c -> chatOfferXC
c -> chatOfferYC
x <- chatOfferXA (in chat with A)
x <- chatOfferXB (do nothing)
x <- chatOfferXC (do nothing)
y <- chatOfferYA (in chat with A)
y <- chatOfferYB (do nothing)
y <- chatOfferYC (do nothing)
x -> acceptOfferXA
y -> acceptOfferYA
a <- acceptOfferXA (in chat with X)
a <- acceptOfferYA (???)
If possible I want to avoid having yet another central server keeping track.
I also don't want to track of every offer server gets. I would like to have it done via protocol.
from How to prevent racing conditions in chat built on with multiple servers?
No comments:
Post a Comment