x


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

more ▼

asked Mar 06 '10 at 11:12 AM

knoggly gravatar image

knoggly
157 7 8 12

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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.

more ▼

answered Mar 06 '10 at 11:55 PM

Murcho gravatar image

Murcho
2.7k 12 23 53

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

Mar 07 '10 at 09:46 AM knoggly
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x697
x235
x175

asked: Mar 06 '10 at 11:12 AM

Seen: 3049 times

Last Updated: Mar 06 '10 at 11:12 AM