Extension issue, mangled or null message

Post here all your questions related with SmartFoxServer .Net/Unity3D API

Moderators: Lapo, Bax

Questionairre
Posts: 16
Joined: 07 Mar 2011, 21:08

Extension issue, mangled or null message

Postby Questionairre » 29 Mar 2011, 02:13

Hey guys,

I am, at this point, just trying to get handleRequest to post a trace.

My code is simple enough :

Unity :

Code: Select all

smartFoxClient.SendXtMessage("testing","TONY",null,SmartFoxClient.XTMSG_TYPE_STR);


AS :

Code: Select all

function init()
{
   trace("Initing testScript");
}      

function handleRequest(cmd, params, user, fromRoom)
{
   trace("Hello world");
}


When I call the Unity line I get this :
[ WARNING ] [id: 15] (SmartFoxServer.readIncomingMessages): Message exceed allowed max length! (0 bytes) from > /127.0.0.1

The thing is this, if instead of a null value I give it some object such as this, from some post on the forums :

Code: Select all

   
         Hashtable msg = new Hashtable();
         msg["type"] = "1";
         msg["id"] = "12345";
         msg["name"] = "Cortana";
                
smartFoxClient.SendXtMessage("testing","TONY",msg,SmartFoxClient.XTMSG_TYPE_STR);


I get nothing on the server console(Win 7/64), log file, or AdminTool. Nothing. I disabled all firewalls, AV and anything else that I could even imagine might interfere with this, but no luck.

I know the extension loads, I get the init trace. The extension is set to the zone where the user is joining, I am still having issues with rooms but the user IS in a room when the sendExtMessage function is called.

Any ideas?

Thanks.
Questionairre
Posts: 16
Joined: 07 Mar 2011, 21:08

Postby Questionairre » 29 Mar 2011, 18:53

I think I fixed it, I realized I was using an older version of the API so I updated to the new one and I took out the type out of the SendXtMessage call, from :

Code: Select all

smartFoxClient.SendXtMessage("testing","trace",null,SmartFoxClient.XTMSG_TYPE_STR);

to :

Code: Select all

smartFoxClient.SendXtMessage("testing","trace",null);
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 29 Mar 2011, 20:16

Best guess I have is, that you should use ArrayList for the parameters.

From the documentation:
* <param name="paramObj">an object (Hashtable for XML and JSON, ArrayList for string) containing the data to be passed to the extension (set to empty object if no data is required).</param>

Try try!!

/Thomas
Full Control - maker of Unity/C# and Java SFS API and indie games
Follow on twitter: http://twitter.com/thomas_h_lund
Questionairre
Posts: 16
Joined: 07 Mar 2011, 21:08

Postby Questionairre » 29 Mar 2011, 22:04

Apparently that is the only case that will work, the one I posted above.

I simplified the code a bit for posting but I currently have something like this :


Unity client :

Code: Select all

private ArrayList userInput = new ArrayList();
userInput.Add(directionVector);
smartFoxClient.SendXtMessage("testing","input",userInput,SmartFoxClientAPI.SmartFoxClient.XTMSG_TYPE_STR);


SFS AS :

Code: Select all

function handleRequest(cmd, params, user, fromRoom)
{
    trace("Command : " + cmd + "\nParameters : " +params + "\nUser : " + user +"\nRoom : " + fromRoom); );
}


When I try to send anything with data I still get :

Code: Select all

2011/03/29 14:58:46.453 - [ WARNING ] [id: 35] (SmartFoxServer.readIncomingMessages): Message exceed allowed max length! (0 bytes) from > /127.0.0.1


And I am using ArrayList in this case.
Questionairre
Posts: 16
Joined: 07 Mar 2011, 21:08

Postby Questionairre » 29 Mar 2011, 22:48

ThomasLund wrote:From the documentation:
* <param name="paramObj">an object (Hashtable for XML and JSON, ArrayList for string) containing the data to be passed to the extension (set to empty object if no data is required).</param>


Also, where was this in the documentation? I can't seem to find it.
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 30 Mar 2011, 00:53

Should be in the API docs for sendXtMesssage

/Thomas
Full Control - maker of Unity/C# and Java SFS API and indie games

Follow on twitter: http://twitter.com/thomas_h_lund
Questionairre
Posts: 16
Joined: 07 Mar 2011, 21:08

Postby Questionairre » 30 Mar 2011, 01:31

ThomasLund wrote:Should be in the API docs for sendXtMesssage

/Thomas


For which API?

Couldn't find it here: http://www.smartfoxserver.com/docs/docP ... dXtMessage

or here : http://www.smartfoxserver.com/docs/docP ... essage.htm


That aside, any idea on what I am doing wrong here?
Questionairre
Posts: 16
Joined: 07 Mar 2011, 21:08

Postby Questionairre » 31 Mar 2011, 00:34

For testing, this is exactly what I am currently doing :

Unity 3.3 C#

Code: Select all

ArrayList blank = new ArrayList();
         smartFoxClient.SendXtMessage("authServer","input",blank,SmartFoxClientAPI.SmartFoxClient.XTMSG_TYPE_STR);

Java Extension

Code: Select all

public void handleRequest(String cmd, String params[], User u, int fromRoom)
   {
trace("Hello World");
}

Same as before, everything is fine until I actually send the message. I get the same error :

Code: Select all

2011/03/30 16:21:13.392 - [ WARNING ] [id: 36] (SmartFoxServer.readIncomingMessages): Message exceed allowed max length! (0 bytes) from > /127.0.0.1


I also tested another extension, the JSONsample, by tossing a trace into it. I get the same thing, so I figure there is something wrong with the call itself.

I have tried both the 1.6.6 server and the patch, 1.6.9. I also tried both the old API, 1.2.6, and the new, 1.2.7. No help. I am quite stumped, I think I followed all the examples, tutorials and advice accurately but it seems that I missed something quite important.
Questionairre
Posts: 16
Joined: 07 Mar 2011, 21:08

Postby Questionairre » 31 Mar 2011, 22:03

After looking around some more I ended up with this :

Java Extension :

Code: Select all

public void handleRequest(String cmd, ActionscriptObject ao, User u, int fromRoom)
   {
       trace("AS Command : " + cmd + "\nParameters : " + "\nUser : " + u.getName() +"\nRoom : " + fromRoom);
      
   }

C# Unity

Code: Select all

Hashtable hashtable = new Hashtable();
         hashtable[1] = "One";
         hashtable[2] = "Two";
         
         smartFoxClient.SendXtMessage("authServer","input",hashtable,SmartFoxClientAPI.SmartFoxClient.XTMSG_TYPE_XML);


And it works just fine. But I am still annoyed that it was this and not the arrayList that worked.

Return to “.Net / Unity3D API”

Who is online

Users browsing this forum: No registered users and 17 guests