Forum ‹ Multiplayer ‹ Do I need to compress a long string in C#?
20 posts
• Page 1 of 1
Do I need to compress a long string in C#?
On UserJoin I need to send a particualr message to the player, like player.Send("loadPreset", scenicsString);
where scenicsString is a very long string.
Do I need to "COMPRESS" this very very long string in C# and uncompress it in AS3, or when using "Send" the message automatically get compressed?
where scenicsString is a very long string.
Do I need to "COMPRESS" this very very long string in C# and uncompress it in AS3, or when using "Send" the message automatically get compressed?
- LorenzGames
- Paid Member
- Posts: 78
- Joined: March 28th, 2010, 3:46 am
Re: Do I need to compress a long string in C#?
LorenzGames wrote:Do I need to "COMPRESS" this very very long string in C# and uncompress it in AS3, or when using "Send" the message automatically get compressed?
The API does not automatically compress strings, no, so if you want to save bandwidth you have to do it yourself.
-

Henrik - .IO
- Posts: 490
- Joined: January 4th, 2010, 1:53 pm
Re: Do I need to compress a long string in C#?
Oh wow, why don't you guys compress? Wouldn't this optimize the communication speed?
But anyway, how do i do it myself? I have no clue how to compress a string in C# and uncompress it in AS3.
But anyway, how do i do it myself? I have no clue how to compress a string in C# and uncompress it in AS3.
- LorenzGames
- Paid Member
- Posts: 78
- Joined: March 28th, 2010, 3:46 am
Re: Do I need to compress a long string in C#?
When you compress data, you save on bandwith but you put additional work on both the server and the client CPU. If the message is not large enough instead of optimizing communication speed you'll get the opposite effect, so it's up to you to decide what should be compressed or not.
- fox1980
- Posts: 205
- Joined: April 1st, 2010, 10:39 pm
Re: Do I need to compress a long string in C#?
Right... I understand the point... but maybe for Oliver would be just a snap of fingers to create a simple compressor class to include in the API?
- LorenzGames
- Paid Member
- Posts: 78
- Joined: March 28th, 2010, 3:46 am
Re: Do I need to compress a long string in C#?
Hey,
I don't think we'll add a compress/decompress thing ourselves. I think there is one built into both C# and ActionScript -- can't you use that? (i'm not sure if it's in the whitelist, but we can add it to the whitelist if it needs to be....)
- Oliver
I don't think we'll add a compress/decompress thing ourselves. I think there is one built into both C# and ActionScript -- can't you use that? (i'm not sure if it's in the whitelist, but we can add it to the whitelist if it needs to be....)
- Oliver
-

Oliver - .IO
- Posts: 1134
- Joined: January 12th, 2010, 8:29 am
Re: Do I need to compress a long string in C#?
Does anybody knows a way to do it, because i have checked on internet and almost all of them uses internal server memory to compress or decompress... also the cross-language compress/decompress is very hard to find...
Please if somebody found a solution post here
Please if somebody found a solution post here
- LorenzGames
- Paid Member
- Posts: 78
- Joined: March 28th, 2010, 3:46 am
Re: Do I need to compress a long string in C#?
In AS3 you can compress stuff by putting it inside a ByteArray and calling the compress() method.
But I dont know how you would decompress the ByteArray in C#...
Just google for third-party libraries in both languages.
But I dont know how you would decompress the ByteArray in C#...
Just google for third-party libraries in both languages.
- Vania
- Paid Member
- Posts: 162
- Joined: March 24th, 2010, 9:01 pm
Re: Do I need to compress a long string in C#?
Yes i have been googling it for the last week...
I know very good how to make a compression/decompression in AS3 with byteArray and base64, but i dont know how to handle it on C#, the problem is that almost all the tutorials on internet use a memory stream which is forbidden on player.io.
I am kinda stuck...
I know very good how to make a compression/decompression in AS3 with byteArray and base64, but i dont know how to handle it on C#, the problem is that almost all the tutorials on internet use a memory stream which is forbidden on player.io.
I am kinda stuck...
- LorenzGames
- Paid Member
- Posts: 78
- Joined: March 28th, 2010, 3:46 am
Re: Do I need to compress a long string in C#?
Okay, did a bit of research:
a) MemoryStream (and other vital classes) are not yet allowed in our whitelist.
b) The .NET zlib Stream is incompatible with Actionscripts ByteArray.uncompress
http://stackoverflow.com/questions/1545 ... uncompress
For now, I'd recommend just sending the long string. We're currently having some discussions internally about whether we should auto-compress and auto-decompress long strings & byte arrays in multiplayer messages.
Best,
Oliver
a) MemoryStream (and other vital classes) are not yet allowed in our whitelist.
b) The .NET zlib Stream is incompatible with Actionscripts ByteArray.uncompress
http://stackoverflow.com/questions/1545 ... uncompress
For now, I'd recommend just sending the long string. We're currently having some discussions internally about whether we should auto-compress and auto-decompress long strings & byte arrays in multiplayer messages.
Best,
Oliver
-

Oliver - .IO
- Posts: 1134
- Joined: January 12th, 2010, 8:29 am
Re: Do I need to compress a long string in C#?
Ok Oliver, at this point I am just waiting for your words.... my string is long... very long, but the good part is that it is mostly recursive text for example you will see similar strings inside that are the same... thats why compressing it will reduce a looooot the size of it.
- LorenzGames
- Paid Member
- Posts: 78
- Joined: March 28th, 2010, 3:46 am
Re: Do I need to compress a long string in C#?
What's the string length?
-

Oliver - .IO
- Posts: 1134
- Joined: January 12th, 2010, 8:29 am
Re: Do I need to compress a long string in C#?
Can go anywhere from few bytes to 1 mb.
It depends on how many custom objects users create on the server, it's all updated realtime becouse they are movable objects and when a new player joins the room he must get the code of all the objects in the room.
So if there are few objects it is fine, but sometimes there are hundreds of objects, and they are all custo made with a code.
It depends on how many custom objects users create on the server, it's all updated realtime becouse they are movable objects and when a new player joins the room he must get the code of all the objects in the room.
So if there are few objects it is fine, but sometimes there are hundreds of objects, and they are all custo made with a code.
- LorenzGames
- Paid Member
- Posts: 78
- Joined: March 28th, 2010, 3:46 am
Re: Do I need to compress a long string in C#?
Okay... I wouldn't wait around for compression support from us though -- we've got a lot on our plates and this is not the #1 priority right now.
I did do a simple calculation. you say "sometimes there are hunderds of objects... Lets say that's 500. And let's also say that one object takes up 100 bytes (i have no idea, but 100 seems like a lot). That's 500*100/1024 = 48kb, which is hardly a lot.
I think you should just send it out uncompressed for now.
Can we see the game?
- Oliver
I did do a simple calculation. you say "sometimes there are hunderds of objects... Lets say that's 500. And let's also say that one object takes up 100 bytes (i have no idea, but 100 seems like a lot). That's 500*100/1024 = 48kb, which is hardly a lot.
I think you should just send it out uncompressed for now.
Can we see the game?
- Oliver
-

Oliver - .IO
- Posts: 1134
- Joined: January 12th, 2010, 8:29 am
Re: Do I need to compress a long string in C#?
well yes i can send them uncompressed for now... is not a big deal, but later on if i have many users and i dont compress somehow i am gonna use a bunch of bandwidth...
I mean the game is not going to be shipped for at least another month... do you think you guys will be able to enable compression by then?
I mean the game is not going to be shipped for at least another month... do you think you guys will be able to enable compression by then?
- LorenzGames
- Paid Member
- Posts: 78
- Joined: March 28th, 2010, 3:46 am
Re: Do I need to compress a long string in C#?
I mean the game is not going to be shipped for at least another month... do you think you guys will be able to enable compression by then?
Sorry, no -- there is too much other stuff in the pipeline already.
Best,
Oliver
-

Oliver - .IO
- Posts: 1134
- Joined: January 12th, 2010, 8:29 am
Re: Do I need to compress a long string in C#?
Is any kind of ETA predictable? so that I can calculate if i can wait ...
- LorenzGames
- Paid Member
- Posts: 78
- Joined: March 28th, 2010, 3:46 am
Re: Do I need to compress a long string in C#?
Hey again,
We have a policy of not stating any deadlines for any product or feature. Sometimes we'll say that something is right around the corner or 'a few days away', but never something that's more than a few days away.
The reason is that priorities will shift and change, and we don't want to be in a situation where we can't keep our promises because of those changes.
My advice would be to evaluate player.io as it is right now, and decide if you can live without the compression feature. Then, when it one day appears, you can consider it an additional bonus feature
Best,
Oliver
We have a policy of not stating any deadlines for any product or feature. Sometimes we'll say that something is right around the corner or 'a few days away', but never something that's more than a few days away.
The reason is that priorities will shift and change, and we don't want to be in a situation where we can't keep our promises because of those changes.
My advice would be to evaluate player.io as it is right now, and decide if you can live without the compression feature. Then, when it one day appears, you can consider it an additional bonus feature
Best,
Oliver
-

Oliver - .IO
- Posts: 1134
- Joined: January 12th, 2010, 8:29 am
Re: Do I need to compress a long string in C#?
ok Oliver... but can use a base64 or bytearray compression made by myself right now or is it somehow forbidden?
- LorenzGames
- Paid Member
- Posts: 78
- Joined: March 28th, 2010, 3:46 am
Re: Do I need to compress a long string in C#?
You can do whatever you want in your serverside code. If the server does not give any error, it's allowed 
- Oliver
- Oliver
-

Oliver - .IO
- Posts: 1134
- Joined: January 12th, 2010, 8:29 am
20 posts
• Page 1 of 1