SendXtMessage problem

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

Moderators: Lapo, Bax

flashbk
Posts: 16
Joined: 08 Jul 2010, 05:45

SendXtMessage problem

Postby flashbk » 04 Aug 2010, 07:46

I am using c# for my client.

my extension code is below

Code: Select all

   
public void handleRequest(String cmd, JSONObject jso, User user, int fromRoom)
{
  trace("handleRequest JSONObject " + cmd);
}

public void handleRequest(String cmd, ActionscriptObject asObj, User user, int fromRoom)
{
  trace("handleRequest ActionscriptObject " + cmd);
}

public void handleRequest(String cmd, String[] data, User user, int fromRoom)
{
  trace("handleRequest String " + cmd);
}

public void handleInternalEvent(InternalEventObject ieo)
{
  trace("handleInternalEvent " + ieo.getEventName());
}


with string

Code: Select all

ArrayList arrayData = new ArrayList();
arrayData.Add(100);
arrayData.Add(200);
arrayData.Add(300);
arrayData.Add(400);
smartfox.SendXtMessage("ZoneMain", "LoginSecondStep", arrayData, SmartFoxClientAPI.SmartFoxClient.XTMSG_TYPE_STR);


it's right, handleRequest is invoked correctly

Code: Select all

[ ZoneMain ]: handleRequest String LoginSecondStep


But xml and json type has problem

Code: Select all

Hashtable xmlData = new Hashtable();
xmlData["0"] = 100;
xmlData["1"] = 200;
xmlData["2"] = 300;
xmlData["3"] = 400;
smartfox.SendXtMessage("ZoneMain", "LoginSecondStep2", xmlData, SmartFoxClientAPI.SmartFoxClient.XTMSG_TYPE_XML);

Hashtable jsonData = new Hashtable();
jsonData["0"] = 100;
jsonData["1"] = 200;
jsonData["2"] = 300;
jsonData["3"] = 400;
smartfox.SendXtMessage("ZoneMain", "LoginSecondStep3", jsonData, SmartFoxClientAPI.SmartFoxClient.XTMSG_TYPE_JSON);


any handler is not invoked.

debug trace show like this

Code: Select all

17:12:03.046 - [ INFO ] > { DATA IN } : <msg t='xt'><body action='xtReq' r='-1'><![CDAT
A[<dataObj><var n='cmd' t='s'>LoginSecondStep2</var><var n='name' t='s'>ZoneMain</var><
obj o='param' t='a'><var n='3' t='n'>400</var><var n='0' t='n'>100</var><var n='1' t='n
'>200</var><var n='2' t='n'>300</var></obj></dataObj>]]></body></msg>
17:12:03.065 - [ INFO ] > { DATA IN } : {"b":{"r":-1,"p":{"3":400,"0":100,"1":200,"2":3
00},"x":"ZoneMain","c":"LoginSecondStep3"},"t":"xt"}


How should I use SendXtMessage with json or xml?
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 04 Aug 2010, 12:41

Unsure what the problem is you are asking about.

From the server console paste, it seems it arrives correct on the server. The content is XML or JSON as expected.

Are you saying that the extension code hooks in the server is not triggered?

/Thomas
flashbk
Posts: 16
Joined: 08 Jul 2010, 05:45

right..

Postby flashbk » 05 Aug 2010, 00:20

yes. my problem is

when I call smartfox.SendXtMessage with XTMSG_TYPE_XML or XTMSG_TYPE_JSON type, extension handler is not triggered.

trace capture is just for info..

XTMSG_TYPE_STR is ok..
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 05 Aug 2010, 05:56

I'm pretty sure that extensions work as expected in the API. Using XML in my own games - similar to how you do it. And the trace from the server shows that the API does format the message according to setting (json data when speifying json etc)

So most likely its an issue of your extension more than the API

Did you override the 3 handlers for each of the 3 datatypes? Can you post your extension code?

/Thomas
flashbk
Posts: 16
Joined: 08 Jul 2010, 05:45

sure..

Postby flashbk » 05 Aug 2010, 06:03

extension code.. there is noting..

Code: Select all

public class ZoneMain  extends AbstractExtension
{
    @Override
    public void init()
    {
    }

    @Override
    public void destroy()
    {

    }

    public void handleRequest(String cmd, JSONObject jso, User user, int fromRoom)
    {
        trace("handleRequest JSONObject " + cmd);
    }

    public void handleRequest(String cmd, ActionscriptObject asObj, User user, int fromRoom)
    {
        trace("handleRequest ActionscriptObject " + cmd);
    }

    @Override
    public void handleRequest(String cmd, String[] data, User user, int fromRoom)
    {
        trace("handleRequest String " + cmd);
    }

    public void handleInternalEvent(InternalEventObject ieo)
    {
        trace("handleInternalEvent " + ieo.getEventName());
    }
}


My Zone config..

Code: Select all

<Zones>
    <Zone name="Bally" customLogin="true" uCountUpdate="true" buddyList="20" maxUsers="4000" >
        <Rooms>
                <!--<Room name="SampleRoom" maxUsers="50" isPrivate="false" isTemp="false" autoJoin="true" uCountUpdate="true" />-->
        </Rooms>

        <AutoReloadExtensions>true</AutoReloadExtensions>
        <Extensions>
            <extension name="ZoneMain" className="ZoneMain" type="java" />
        </Extensions>
    </Zone>
</Zones>
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 05 Aug 2010, 06:30

And last question for now - are you running version 1.2.5 of the API?

Remember that I fixed a bug in this area in one of the last updates (longish time ago, but still).

/Thomas
flashbk
Posts: 16
Joined: 08 Jul 2010, 05:45

1.2.5

Postby flashbk » 05 Aug 2010, 08:20

I am using 1.2.5 version with smartfox server 1.6.6

If client not enter a room and call SendXtMessage with XTMSG_TYPE_STR, server side handlerRequest is triggered correctly.

If client enter a room and call SendXtMessage with XTMSG_TYPE_XML or XTMSG_TYPE_STR, server side handlerRequest is triggered correctly.

SendXtMessage with XTMSG_TYPE_JSON, handlerRequest is never triggered.

Below client code is not correct?

Code: Select all

Hashtable jsonData = new Hashtable();
jsonData["0"] = 100;
jsonData["1"] = 200;
jsonData["2"] = 300;
jsonData["3"] = 400;
smartfox.SendXtMessage("ZoneMain", "LoginSecondStep3", jsonData, SmartFoxClientAPI.SmartFoxClient.XTMSG_TYPE_JSON);

Return to “.Net / Unity3D API”

Who is online

Users browsing this forum: No registered users and 9 guests