So...
Most of the GCastController
data was only used by the new thread you were creating. So instead of using a bunch of Arcs and Mutexes, I've moved all the data used by the thread inside the GCastControllerBackend
struct.
Then I splitted the big match
in multiple methods of GCastControllerBackend
.
Everything should work pretty much the same as before.
This is the only effective change I'm aware of:
send!(self.app_sender, Action::PlaybackStop);
This is not inside an if statement anymore, so it will be executed even when self.device_ip
is empty.
But I think it's not a big deal.
There is a recursive cycle in the heart_beat method... I've already solved it, but I want to clean the code a bit more before pushing