Performace Overhit for String Concatenation in Online Pool Game

Hi,

guys plz help me regarding long string concatenation!

i m making online pool game in which for pool ball movement sync to other players, i m broadcasting player(whoes turn is ) to other players and applying to other player balls!

when i m doing string concatenation i results in heavy performance overhit and ball jittering much!
i m just sending data 10 times/second,

below are some code snippest i tried,

StringBuilder sbData = new StringBuilder(10000);
		if (timeLastSending >= sendingPeriod) 
		{
			foreach(KeyValuePair<string, GameObject> kv in playerBalls)
			{
				if(kv.Value.rigidbody.velocity.magnitude > 0.005f)
				{
					kv.Value.rigidbody.useGravity = true;
					sbData.AppendFormat("{0:.000000},{1:.000000},{2:.000000},{3:.000000},{4:.000000},{5:.000000},{6},", 
													kv.Value.transform.position.x, kv.Value.transform.position.y, kv.Value.transform.position.z, 
															kv.Value.transform.position.x, kv.Value.transform.position.y, kv.Value.transform.position.z, kv.Key);
					//print("SEND");
					gameInstance.PlayerMoveMade(sbData.ToString());
					sbData.Remove(0, sbData.Length);
				}	
			}
			timeLastSending = 0;
			return;

i also tried for this one…

				if(gameRulesScript.isGameStart  gameRulesScript.isSendBallData) // for the player whose' turn is
				{	
					for(short i = 0; i < 15; i++)
					{	
						if(balls[ballNo] != null)
						{
							balls[ballNo].rigidbody.useGravity = true;
							data = string.Format("ball{0:smile:2},{1:.000000},{2:.000000},{3:.000000},{4:.000000},{5:.000000},{6:.000000},", ballNo + 1, balls[ballNo].transform.position.x, balls[ballNo].transform.position.y, balls[ballNo].transform.position.z, 
																																	balls[ballNo].transform.localEulerAngles.x, balls[ballNo].transform.localEulerAngles.y, balls[ballNo].transform.localEulerAngles.z); 				
							StartCoroutine("Move1");
						}	
						ballNo++;
						if(ballNo > 14) ballNo = 0;
					}	
				}

on opponent side also when i m spliting it it takes lots of load !

please help me, is their any other better way so that this can be achieved at no performance overhit and game runs sooth like any other pool game!

Thankx!

Don’t use strings. Send the actual bytes of data instead.

how can i send bytes to game server, need to broadcast all ball positions and rotations in same frame!

Put a NetworkView on every ball and sync the data with RPC calls. Should work fine since it looks like all you’re sending are string and Vector3. Alternately - if you’re syncing position, set the NetworkView to observe the transform.

Hi KesloMRK,

i m using SmartFoxServer in back end, which doesn’t support Unity3d Network View and RPC at all, what it support is, data transmission and broadcasting in format of String, int, float, double, byte and array of all only!

That webpage lists Unity3D as a supported platform. Also, when you send stuff over network, in the end, it’s always bytes.