Im trying to convert a byte array to a string so that I can send it to other connections on the network, but NetworkView.RPC() seems to be cutting my string short for some reason.
Server code:
var bytes:byte[] = worldManager.worldGrids[i].cells[j].ReadBytes(mapName);
var enc:System.Text.Encoding = System.Text.Encoding.ASCII;
var texData:String = enc.GetString(bytes);
Debug.Log(bytes.length); //prints about 109 which is correct
Debug.Log(enc.GetBytes(texData).length); //prints about 109 which is correct
networkView.RPC("ReceiveCells",viewID.owner,0,mapName,texData);
Client code:
var enc:System.Text.Encoding = System.Text.Encoding.ASCII;
var bytes:byte[] = enc.GetBytes(texData);
SendChatMessage("Server",mapName+" "+bytes.length, "Client"); //prints 8 :(
worldManager.worldGrids[0].cells[0].SaveBytes(mapName,bytes);
It seems that only 8 bytes of the original 109 bytes are making it through the NetworkView.RPC() function. Is there some special character in a string that will cause that function to kill the rest of the string? How could I get around this without sending unneeded data across the network? The data im sending is a png file.