Forum Multiplayer Passing unknown number of parameters into MessageHandler?

Discussion and help relating to the Player.IO Multiplayer API

Passing unknown number of parameters into MessageHandler?

Postby Breaker » January 24th, 2012, 7:43 am

Just a quick question, is it possible to pass in and handle and unknown number of arguments into a message handler? For example I noticed you can't use arguments properties or the ...rest keyword. Was just wondering if it was intended or if there was a way to do it. Thanks.

Toby wrote:You can just create a Message object and then use the .add() method for each item you want to send before sending it off. Then when you receive it you can just use the count to find out how many params you should be reading. :)

Image
Last edited by Breaker on January 25th, 2012, 2:37 am, edited 1 time in total.
User avatar
Breaker
 
Posts: 4
Joined: January 19th, 2012, 7:27 pm

Re: Passing unknown number of parameters into MessageHandler

Postby Toby » January 24th, 2012, 7:09 pm

You can just create a Message object and then use the .add() method for each item you want to send before sending it off. Then when you receive it you can just use the count to find out how many params you should be reading. :)
User avatar
Toby
 
Posts: 85
Joined: January 14th, 2010, 4:01 pm


Return to Multiplayer



cron