Client API version 1.0.3 with the new smartfox version

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

Moderators: Lapo, Bax

saqibumar
Posts: 6
Joined: 11 Mar 2015, 21:46

Client API version 1.0.3 with the new smartfox version

Postby saqibumar » 23 Mar 2015, 09:20

Hi,
We have smartfox server version 2.9.2 and we have a C# client api (version 1.0.3, runtime version v4.0.30319)
is the old client api compatible with the latest smartfox server?

There are no errors in the boot log.
I can see the connected users when i debug the client app, however I noticed that onExtensionResponse(BaseEvent evt) is never being called. We believe there's something missing on the server still as this client app had been live and running with the old smartfox server versions.
We were able to resolve most of the server errors but this one below: The following error is causing connected users list to be displayed on the client app (C#)

Code: Select all

java.lang.NullPointerException:
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Exception: java.lang.NullPointerException
Message: *** Null ***
Description: Error while handling client request in extension: { Ext: bdizzleExtension, Type: JAVA, Lev: ZONE, { Zone: boomdizzle }, {} }
Extension Cmd: ListManager.getZoneUsers
+--- --- ---+
Stack Trace:
+--- --- ---+
sfs2x.extension.bdizzle.src.ListManager.getUsers(ListManager.java:98)
sfs2x.extension.bdizzle.src.ListManager.handleClientRequest(ListManager.java:61)
com.smartfoxserver.v2.extensions.SFSExtension.handleClientRequest(SFSExtension.java:208)
com.smartfoxserver.v2.controllers.v290.ExtensionReqController.processRequest(ExtensionReqController.java:174)
com.smartfoxserver.v2.controllers.v290.ExtensionReqController$1.run(ExtensionReqController.java:68)
java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


Your help would be highly appreciated as this has been an issue for over 2 weeks now.
Thank you
User avatar
Lapo
Site Admin
Posts: 23025
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Client API version 1.0.3 with the new smartfox version

Postby Lapo » 23 Mar 2015, 10:35

Hi,
the server side error indicates a problem in your code:

Code: Select all

sfs2x.extension.bdizzle.src.ListManager.getUsers(ListManager.java:98)


A null pointer exception is thrown at the line 98. I'd recommend checking your Extension code.

Cheers
Lapo
--
gotoAndPlay()
...addicted to flash games
saqibumar
Posts: 6
Joined: 11 Mar 2015, 21:46

Re: Client API version 1.0.3 with the new smartfox version

Postby saqibumar » 23 Mar 2015, 11:23

Thank you for the response. We were able to fix the issue. Now we have the following on the client side.

Code: Select all

Unable to cast object of type 'Sfs2X.Entities.Data.SFSObject' to type 'Sfs2X.Entities.Data.SFSArray'.


Looks like we are missing some variable settings in smartfox. I can see uid in zone monitor under user monitoring but the extension code has 3 other variables that i can't figure out.

The code in extension is following. It returns the array. I believe uid is being read from the runtime variable.

Code: Select all

for (int i = 0; i < list.size(); i++)
    {
      row = (SFSUser)list.get(i);
      item = new SFSObject();
      item.putInt("id", row.getId());
      item.putInt("uid", row.getVariable("uId").getIntValue().intValue());
      item.putUtfString("name", row.getVariable("displayName").getStringValue());
      item.putUtfString("emailAddress", row.getVariable("emailAddress").getStringValue());
     
      returnArr.addSFSObject(item);
    }

On the client side the code is

Code: Select all

int userId = (int)((SFSArray)((SFSArray)((SFSArray)((SFSArray)((SFSObject)evt.Params["params"]).GetClass("results")).GetWrappedElementAt(i).Data).GetWrappedElementAt(4).Data).GetWrappedElementAt(6).Data).GetWrappedElementAt(2).Data;
User avatar
Lapo
Site Admin
Posts: 23025
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Client API version 1.0.3 with the new smartfox version

Postby Lapo » 23 Mar 2015, 16:05

Is the last piece of code for real? :D
Does it even compile? If it does, good for you, but no human being would be able to decode what the heck is going on in there! There are 6 type casts in a row :shock:

The most interesting part is that there is a GetClass() call in the middle, which you proceed to deconstruct manually, which I find bizarre.

The whole purpose of get/putClass() is to simplify transporting object to/from the server by means of custom defined objects, so that you can just read the data via its accessors instead of all this manual work.

The code should work along these lines:

Code: Select all

ISFSObject params = evt.Params["params"];
SomeClass obj = (SomeClass) params.GetClass("results");

// read the id
int userId = obj.Id;


By the way in your server-side example there's no reference to a putClass call, so I am still quite confused.

Thanks
Lapo

--

gotoAndPlay()

...addicted to flash games
saqibumar
Posts: 6
Joined: 11 Mar 2015, 21:46

Re: Client API version 1.0.3 with the new smartfox version

Postby saqibumar » 25 Mar 2015, 23:26

The client code is live and tested with the old smartfox server without issues. Our issue is smartfox. I don't have any experience with smartfox server. Do we need action script or Unity in order to make it work? Looks like most of our calls are missing in the provided jar file.
What's the best way to implement users collaboratoin through the app.

Thank you for your responses.
User avatar
Lapo
Site Admin
Posts: 23025
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: Client API version 1.0.3 with the new smartfox version

Postby Lapo » 26 Mar 2015, 09:06

saqibumar wrote:The client code is live and tested with the old smartfox server without issues. Our issue is smartfox. I don't have any experience with smartfox server. Do we need action script or Unity in order to make it work?

Actionscript is the development language in Flash. The code you have posted is C#, so I presume you're using Unity or another C# based environment? Correct?

Looks like most of our calls are missing in the provided jar file.

I am not sure what you are talking about. The code you have posted last time had to do with a custom Extension request.

The first thing I would like to understand is what version of SmartFoxServer 2X you were running before the update. If you have skipped many releases you would probably be better off by simply downloading the latest C# API and recompile your client.
In fact the C# API version 1.0.3 (your current version) are very old. The current release is 1.5.x and lots of fixes have been introduced since the version you're using.

You can download the latest API here:
http://www.smartfoxserver.com/download/sfs2x#p=client

Cheers
Lapo

--

gotoAndPlay()

...addicted to flash games

Return to “SFS2X C# API”

Who is online

Users browsing this forum: No registered users and 17 guests