Some problem in Unity3D

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

Moderators: Lapo, Bax

haha0738
Posts: 11
Joined: 20 Nov 2009, 04:30

Some problem in Unity3D

Postby haha0738 » 20 Nov 2009, 04:35

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>
User avatar
Lapo
Site Admin
Posts: 23007
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 20 Nov 2009, 05:54

Hi,
I moved to the C#/Unity section, so that Thomas can see it.
Lapo
--
gotoAndPlay()
...addicted to flash games
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 20 Nov 2009, 13:01

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
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 21 Nov 2009, 11:47

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
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 21 Nov 2009, 11:53

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
haha0738
Posts: 11
Joined: 20 Nov 2009, 04:30

Postby haha0738 » 23 Nov 2009, 07:09

thanks for your help^^
I think I have been solved the problem.
I use SendXtMessage method
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 23 Nov 2009, 07:13

Super!

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

/Thomas

Return to “.Net / Unity3D API”

Who is online

Users browsing this forum: No registered users and 21 guests