I am wondering if it is because I am calling clients.lock too much.
I can see the log statement from line 192 printed in my console when I'm running the server locally, but it never gets to line 198...
I want to keep this Mutex list of connected clients, and when I need to "blast a message" it seems like I need to have a mutable reference to each client. But I am also saving other data for my game like player x and y position which I need to mutate... maybe having a two different hashmaps, each with client uuid as the key would solve my problems here? Or should I move some of the matches inside out of each other?
I know this code is kind of messy but curious for advice on how to get this working / efficient / elegantly written. Thanks
I still don't really fully know what's happening with clients.lock().await
There is no .unlock function on the mutext guard... so is that just handled automatically by Rust? The way I'm understanding it is that as soon as you get to the closing curly brace that ends the scope where you created the mutext guard then it will be unlocked and therefore available to be locked again... but is that how it actually works?
Now I'm doing something like this. Not sure if I really needed to split out the sender into its own hashmap, but the message handler function does seem a lot easier to follow now I think.