Allowing to switch to websockets transparently

Hello,
Just dug a bit deeper livewire, so sorry if I’m posting nonsense.

I’m thinking of using livewire for a chat feature (among a lot of other stuff the app does already : https://github.com/agorakit/agorakit), to replace maybe unpoly js (which by the way is really cool as well, altough unknown lib). The app might or might not be hosted with websocket ability since it’s open source and installable by various people. So it would be really cool to have the choice of using websockets/pusher/wathever or not (ajax poling then).

Since livewire is innovative on a lot of grounds, I think it would be ubber cool to be able to enable “real” realtime on some interactions with a simple parameter change on the livewire components markup. On the backstage, it would do the right thing to connect to echo, and handle all the hard stuff and abstract it to the user/developer. Or even better, enable websocket and fallback to ajax when websocket is not available. Like auto/manual switching of transport. Abstracting completely the transport used.

Can this be done? Is it a good idea? Is it a good challenge for livewire? I let you decide :slight_smile:

I don’t think it would be hard because it’s all there for you already. I would assume you could just check the broadcast driver env variable (or create your own for a toggle), use a dynamic listener for echo if its being used, and use a conditional to insert polling if it’s not.