You've modeled this as a finite state machine?
Discussion
What exactly? The fallback logic is actually quite naive right now, as it will never retry websockets after falling back to polling. However processes are usually short lived enough that it doesn’t matter
This article is quite good at explaining: https://wickstrom.tech/2017-11-10-finite-state-machines-part-1-modeling-with-haskell.html
Don't get hung up on the language though. Anyway, using something like this may help how you structure your code.
followed