Page 1 of 1

Some problem in Unity3D

Posted: 20 Nov 2009, 04:35
by haha0738
I use C# to develope my game.
I send a SFSObject from client, but I can't handle it on

Code: Select all

public void handleRequest(String cmd, ActionscriptObject ao, User fromUser, int fromRoom)

Have any on can tell me how to receive the object in jave extension?

this is the message what I send form client

Code: Select all

[SFS]: [Sending]: <msg t='sys'><body action='asObj' r='37'><![CDATA[<dataObj><var n='y' t='n'>139.7987</var><var n='z' t='n'>293.0069</var><var n='_cmd' t='s'>t</var><var n='ry' t='n'>0</var><var n='rz' t='n'>0</var><var n='rx' t='n'>0</var><var n='w' t='n'>1</var><var n='x' t='n'>901</var></dataObj>]]></body></msg>

Posted: 20 Nov 2009, 05:54
by Lapo
Hi,
I moved to the C#/Unity section, so that Thomas can see it.

Posted: 20 Nov 2009, 13:01
by ThomasLund
Hey

I'll need a little more info - I take it that you are sending the message from Unity API as an XML.

I also take it that you've used the Java extension template (or something similar) from here
http://www.smartfoxserver.com/docs/inde ... mplate.htm

Do you get any errors on the server console? Can you do everything else (login, connection etc), so that its possible to rule out network connectivity?

I got extensions working and a lot of other people too - so we will pretty certainly crack this nut

Best
Thomas

Posted: 21 Nov 2009, 11:47
by ThomasLund
Hi

I just made a small test example, and I dont have any issues in this regards.

In Unity:

Code: Select all

   smartFox.SendXtMessage("testExt", "testMethod", null, SmartFoxClient.XTMSG_TYPE_XML);
   smartFox.SendXtMessage("testExt", "testMethod", null, SmartFoxClient.XTMSG_TYPE_JSON);
   smartFox.SendXtMessage("testExt", "testMethod", null, SmartFoxClient.XTMSG_TYPE_STR);


And then I made a small java extension based on the template. Here is the code.

Code: Select all


import it.gotoandplay.smartfoxserver.data.*;
import it.gotoandplay.smartfoxserver.extensions.*;
import it.gotoandplay.smartfoxserver.lib.ActionscriptObject;
import it.gotoandplay.smartfoxserver.events.InternalEventObject;

import org.json.JSONObject;

public class testExt extends AbstractExtension
{

   public void init()
   {
      trace("Extension initialized");
   }

   public void destroy()
   {
      trace("Extension destroyed");
   }

   public void handleRequest(String cmd, ActionscriptObject ao, User u, int fromRoom)
   {
      trace("XML extension called");
   }

   public void handleRequest(String cmd, JSONObject jso, User u, int fromRoom)
   {
      trace("JSON extension called");
   }

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

   public void handleInternalEvent(InternalEventObject ieo)
   {
      // Your code here, handles server events
   }
}


On the server console comes up:

Code: Select all

[ testExt ]: XML extension called
[ testExt ]: JSON extension called
[ testExt ]: String extension called


So I'll need more info from you to be able to help

/Thomas

Posted: 21 Nov 2009, 11:53
by ThomasLund
AHHHHHHHHH

So much for reading the details before trying to fix your problem.

You are not sending via extensions.....!

You seem to be using the SendObject method if I read the XML correct. So that is not handled in handleRequest, but in public void handleInternalEvent(InternalEventObject ieo) if I recall correctly.

handleRequest is purely used for SendXtMessage type communication.

Hope that helps you along

/Thomas

Posted: 23 Nov 2009, 07:09
by haha0738
thanks for your help^^
I think I have been solved the problem.
I use SendXtMessage method

Posted: 23 Nov 2009, 07:13
by ThomasLund
Super!

Good luck on your project, and you are more than welcome to ask questions here + in the other parts of the forum

/Thomas