Forum Multiplayer Do I need to compress a long string in C#?

Discussion and help relating to the Player.IO Multiplayer API

Do I need to compress a long string in C#?

Postby LorenzGames » September 2nd, 2010, 2:17 am

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?
LorenzGames
Paid Member
 
Posts: 78
Joined: March 28th, 2010, 3:46 am

Re: Do I need to compress a long string in C#?

Postby Henrik » September 2nd, 2010, 10:20 am

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.
User avatar
Henrik
.IO
 
Posts: 490
Joined: January 4th, 2010, 1:53 pm

Re: Do I need to compress a long string in C#?

Postby LorenzGames » September 2nd, 2010, 12:08 pm

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.
LorenzGames
Paid Member
 
Posts: 78
Joined: March 28th, 2010, 3:46 am

Re: Do I need to compress a long string in C#?

Postby fox1980 » September 2nd, 2010, 12:21 pm

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#?

Postby LorenzGames » September 2nd, 2010, 12:41 pm

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#?

Postby Oliver » September 3rd, 2010, 11:07 am

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
User avatar
Oliver
.IO
 
Posts: 1134
Joined: January 12th, 2010, 8:29 am

Re: Do I need to compress a long string in C#?

Postby LorenzGames » September 3rd, 2010, 11:34 am

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 :)
LorenzGames
Paid Member
 
Posts: 78
Joined: March 28th, 2010, 3:46 am

Re: Do I need to compress a long string in C#?

Postby Vania » September 5th, 2010, 6:53 am

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.
Vania
Paid Member
 
Posts: 162
Joined: March 24th, 2010, 9:01 pm

Re: Do I need to compress a long string in C#?

Postby LorenzGames » September 5th, 2010, 12:29 pm

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... :(
LorenzGames
Paid Member
 
Posts: 78
Joined: March 28th, 2010, 3:46 am

Re: Do I need to compress a long string in C#?

Postby Oliver » September 6th, 2010, 10:41 am

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
User avatar
Oliver
.IO
 
Posts: 1134
Joined: January 12th, 2010, 8:29 am

Re: Do I need to compress a long string in C#?

Postby LorenzGames » September 6th, 2010, 12:20 pm

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#?

Postby Oliver » September 6th, 2010, 1:51 pm

What's the string length?
User avatar
Oliver
.IO
 
Posts: 1134
Joined: January 12th, 2010, 8:29 am

Re: Do I need to compress a long string in C#?

Postby LorenzGames » September 6th, 2010, 1:57 pm

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.
LorenzGames
Paid Member
 
Posts: 78
Joined: March 28th, 2010, 3:46 am

Re: Do I need to compress a long string in C#?

Postby Oliver » September 6th, 2010, 5:14 pm

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
User avatar
Oliver
.IO
 
Posts: 1134
Joined: January 12th, 2010, 8:29 am

Re: Do I need to compress a long string in C#?

Postby LorenzGames » September 6th, 2010, 5:24 pm

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?
LorenzGames
Paid Member
 
Posts: 78
Joined: March 28th, 2010, 3:46 am

Re: Do I need to compress a long string in C#?

Postby Oliver » September 7th, 2010, 2:47 pm

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
User avatar
Oliver
.IO
 
Posts: 1134
Joined: January 12th, 2010, 8:29 am

Re: Do I need to compress a long string in C#?

Postby LorenzGames » September 7th, 2010, 2:56 pm

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#?

Postby Oliver » September 7th, 2010, 3:06 pm

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
User avatar
Oliver
.IO
 
Posts: 1134
Joined: January 12th, 2010, 8:29 am

Re: Do I need to compress a long string in C#?

Postby LorenzGames » September 7th, 2010, 3:23 pm

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#?

Postby Oliver » September 7th, 2010, 3:48 pm

You can do whatever you want in your serverside code. If the server does not give any error, it's allowed ;)

- Oliver
User avatar
Oliver
.IO
 
Posts: 1134
Joined: January 12th, 2010, 8:29 am


Return to Multiplayer



cron