Closed Gskartwii closed 5 years ago
Should not really be using CallPlayerAsync, here's a good explanation why.
https://www.youtube.com/watch?v=0H_xcA-0LDE
It will also be removed in a future release of rbx-net.
You should now be using NetServerAsyncFunction
and NetClientAsyncFunction
for this.
I will look into having it properly deal with async functions.
Background info: I'm using rbx-net with roblox-ts to create a turn-based game. A network design pattern that feels idiomatic for the game is to have a RemoteFunction named "AskPlay" that waits for the player to give input and then resolves a Promise. On the server, this is easy to do, as
CallPlayerAsync
returns a Promise.However, I can't set the client callback to be an
async
function, asasync
functions return aPromise
thatrbx-net
doesn't wait for to be resolved. As a result, I can'tawait
for the player to make their choice. So ideally, I would like my code to look like this:Here
this.AskPlay()
returns a Promise that is resolved upon user input. Could it be that this design isn't in line with how rbx-net is designed to work?