- Home /
RPC return value
Hello,
is there easy way to let RPC's return a value? I think it's a very common usecase to use a RPC to obtain data from another machine, and without a return value thats much more difficult.
One solution could be of a custom 2-way communication where one first calls the RPC and then the target invokes "back" another defined RPC on the caller to return the result. Isn't that a bit oversized?
Anybody some ideas?
regards knoggly
Answer by Murcho · Mar 06, 2010 at 11:55 PM
The reason there is no return value is that the function would have to wait for a response from another machine to continue execution, at least in your example there, which can take quite a while. This becomes a problem when you are running a single threaded program (Unity only uses one thread) and execution is stalled for what is an unknown time.
Your suggestion for a two way system there is right however. Call an RPC function from the server directed at a client. When the client receives the RPC, the client sends another RPC call back to the server with the relevant information the server requested. This can be done the opposite way as well.
Allright, I'm aware of the blocking nature of an RPC, but in some cases (e.g. initialization) that is no problem or even wanted.
Nevertheless, thanks for your answer, supporting my first idea :)
cheers
Your answer
![](https://koobas.hobune.stream/wayback/20220612100103im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Problem with networking 2 Answers
Send model/GameObject from Server to Client 0 Answers
Very Strange RPC error 1 Answer
Acess server stuff by the client 0 Answers