- Home /
RPC with a string argument - working for 1st connected player only...
Hi to all!
I'm sending a string(2-7 chars long) as an RPC param. Works like a charm for the first connected player, but for the second, debug shows on the server side sentString.length = 4, and on the client side receivedString.length = 0 !!! The function is called, the player is connected.
Server side :
Debug.Log(stringToSend.length); //Debugs 4
networkView.RPC("ReceiveString",Network.connections[1],stringToSend);
Client side(player 1) :
@RPC
function ReceiveString(str : String)
{
Debug.Log(str.length); //Debugs 0
}
Am networking an iPad 1, an iPad 3 and an iMac. Whoever is the server, same result. Always the second player to connect receiving an empty string. Receives previous initialization RPCs fine, though...
Any ideas???
Thanks!
Edit for precision's sake : networking through wifi. Tried strings of various lengths with the same result.
Edit2 : got it to work in a minimal scene, but not in my actual set up. Here's my exact code: Server side
if(GUI.Button (new Rect(310,40,80,30),"SendNotes"))
{
var stringToSend : String = StaticFunctions.NotesToString(notes);
//notes is a List of enum Notes
print("sending string of length "+stringToSend.Length);
//The above debugs 4
networkView.RPC("ReceiveNotes_RPC",Network.connections[players.selectedPlayer],stringToSend);
}
client side:
@RPC
function ReceiveNotes_RPC(str:String)
{
Debug.Log("received notes : "+str.length);
//the above debugs 0
pattern.notes = StaticFunctions.StringToNotes(str);
pattern.CreateClipFromNotes();
}
Out of despair, I went the simpler route: sending multiple RPCs containing an int each, ins$$anonymous$$d of converting List. to String and back. Works fine, but still no idea why my previous, maybe more efficient(?) solution wasn't working out...
No I've no idea - just looks like it should work doesn't it :(
If you want to send a $$anonymous$$essage to all connected players you need to pass RPC$$anonymous$$ode.Others
as the second argument of the RPC call. This may be what your looking for :)
i dont think anyone has figured this out yet, im on the same page as you and im supprised this has been overlooked