Strings sent from server with unmatched curly braces vanish

Post here your questions about the Unity / .Net / Mono / Windows 8 / Windows Phone 8 API for SFS2X

Moderators: Lapo, Bax

Molix
Posts: 40
Joined: 01 Apr 2009, 19:34
Location: Toronto, ON, Canada

Strings sent from server with unmatched curly braces vanish

Postby Molix » 09 Apr 2013, 02:58

I discovered that if I send a message with a string in it that contains unmatched curly braces, it never shows up. I am torn between hoping there is something obvious and hoping that this is actually an issue (so I don't feel like I totally wasted today).

e.g.

Code: Select all

response.putUtfString( "test",
      "Sending 4 strings, 1 ok, 2 single open brace, 3 single close brace, 4 done" );   
zoneExtension.send( "testCommand", response, user );
   
response.putUtfString( "test",
      "(1) Matching curly braces { and }" );   
zoneExtension.send( "testCommand", response, user );
         
response.putUtfString( "test",
      "(2) Single open brace { ... uh-oh" );   
zoneExtension.send( "testCommand", response, user );
         
response.putUtfString( "test",
      "(3) Single close brace } ... nuh-uh" );   
zoneExtension.send( "testCommand", response, user );
         
response.putUtfString( "test",
      "(4) Done" );   
zoneExtension.send( "testCommand", response, user );


On the client I only see:

Code: Select all

"Sending 4 strings, 1 ok, 2 single open brace, 3 single close brace, 4 done"
"(1) Matching curly braces { and }"
"(4) Done"


Can anyone confirm?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Strings sent from server with unmatched curly braces van

Postby Lapo » 09 Apr 2013, 08:17

Are you actually printing those strings out on the client side? Or are you just watching the SFSObject dump?
The dump uses braces internally (I don't remember which type) to pretty-print the object structure.
Lapo
--
gotoAndPlay()
...addicted to flash games
Molix
Posts: 40
Joined: 01 Apr 2009, 19:34
Location: Toronto, ON, Canada

Re: Strings sent from server with unmatched curly braces van

Postby Molix » 09 Apr 2013, 12:42

Client-side my handler gets nothing. Even just dumping the whole message, i.e. it is either not sent to the client, or the client API does not pass it through.

Code: Select all

private void ERH_Test( SFSObject sfsData )
{
   Debug.Log ( "Test command response: " + sfsData.GetDump() );
   string msg = sfsData.GetUtfString( "test" );         
   Debug.Log( msg );
}
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Strings sent from server with unmatched curly braces van

Postby Lapo » 09 Apr 2013, 13:19

Curly braces are used as special characters for pretty-printing object dumps. If you have turned on the debug feature in the API you should see an error in the console, if you're sending strings containing an uneven number of open/closed curly braces.

You can either avoid to use curly braces (substitute them with other brackets) or turn off the debug.

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
Molix
Posts: 40
Joined: 01 Apr 2009, 19:34
Location: Toronto, ON, Canada

Re: Strings sent from server with unmatched curly braces van

Postby Molix » 09 Apr 2013, 13:51

Thanks. For clarity, it works as expected if during the creation of our SmartFox object in Unity/C# we do

Code: Select all

smartFox = new SmartFox( false );


It is worth noting that even player chat with a single brace is lost if the debug is turned on, so presumably we need to modify people's chat text when sending it and then un-modify it at the other end, as well as check all strings entered by the designers. Are there any other special characters we need to handle?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Strings sent from server with unmatched curly braces van

Postby Lapo » 09 Apr 2013, 14:26

Yes, that line of code turn off the debugging.

I don't think you need to do anything special with the curly brackets character, just be aware that the problem exists when the DEBUG is turned on. There's no need to modify anythings because in production you will not run the debugging mode.
Lapo

--

gotoAndPlay()

...addicted to flash games
Molix
Posts: 40
Joined: 01 Apr 2009, 19:34
Location: Toronto, ON, Canada

Re: Strings sent from server with unmatched curly braces van

Postby Molix » 09 Apr 2013, 15:45

What we normally have is:

Code: Select all

smartFox  = new SmartFox( Application.isEditor || Debug.isDebugBuild );

i.e. we're automatically in debug if we're developing, and not when we release.

Hopefully you can fix the issue in a future release. In the meantime we'll do as you suggest, but obviously it is not a good permanent solution, since we could be masking dozens of problems and only see them when we need to debug something else.

Thanks for your help.

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 29 guests