SendXtMessage problem

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

Moderators: Lapo, Bax

duke
Posts: 31
Joined: 16 Apr 2009, 11:23

SendXtMessage problem

Postby duke » 26 Apr 2009, 06:03

I've probably just missed something here:
-C# / Unity3D
-The command is definitely being sent on the client side.
-All my extensions operate on the zone rather than per room (for the moment anyway).

Relevant lines from client:

Code: Select all

extensionName = "moo_exchange";
       
smartFox.SendXtMessage(extensionName, "GetMyInfo", paramObj, SmartFoxClient.XTMSG_TYPE_XML);


..and server (moo_exchange.class, definitely loading in SFS):

Code: Select all

public void handleRequest(String cmd, ActionscriptObject aso, User user, int fromRoom)
   {   
      trace("Request received"+ cmd.toString());
      
      if (cmd.equals("GetMyInfo"))
      {
         trace("User requested GetMyInfo");
      }
   }


I should get at least "Request received" but I get nothing!
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 26 Apr 2009, 18:32

Hi

99% sure that the problem you run into is not having joined a room before trying to communicate with the extension.

I dont even know if this is documented, but it seems that you have to not only be logged in but also joined a room - even if your extension is a zone level extension.

At least here I can reproduce your problem if I try to communicate after login, but before joining the room. If I'm logged in AND joined a room, then there is no problem here at least.

Try and report back!

/Thomas
duke
Posts: 31
Joined: 16 Apr 2009, 11:23

Postby duke » 26 Apr 2009, 23:22

Actually I think I know why. I wanted to keep the login/authentication completely seperate from the game, so I followed the island demo, but had some problems invoking the smartfox client using from Smartfox.cs, so I simply made a new SmartFoxClient. So I think i just have a new client sitting there, with no relation to the logged in client. I'll look into it further tonight.
duke
Posts: 31
Joined: 16 Apr 2009, 11:23

Postby duke » 27 Apr 2009, 07:36

Forgot a crucial part of the code that throws the current client to the SmartFox class:

Code: Select all

   void OnConnection(bool success, string error) {
      if ( success ) {
         SmartFox.Connection = smartFox;


Now my debugging stuff says im both sending the message and receiving a response :)
Fishypants
Posts: 57
Joined: 26 Oct 2010, 14:03
Location: South Pasadena California
Contact:

Postby Fishypants » 27 Dec 2010, 00:14

Hey Thomas,

I believe I am having the issue you are describing, where I am logged into a zone, but not a room, yet I cannot call any zone extensions . . .

This as I see it could be a problem, as I have an user account creation page in my Unity setup, where you create a new account and it submits it to the MySQL database, then you can log it.

How would you go about this if you can't run extensions at the zone level?
Fishypants
Posts: 57
Joined: 26 Oct 2010, 14:03
Location: South Pasadena California
Contact:

Postby Fishypants » 27 Dec 2010, 03:14

Ok so this is my solution for now:

Basically I have a Login zone, and a CreateAccount zone.

Login has customLogin=true, and validates the users information against a MySQL database query. CreateAccount does not.

On the main screen you can either log in, or create a new account. If you create a new account, I join CreateAccount zone with no username or pass (so hopefully smartfox will assign its own incremented user name). Once in the zone, I have access to the smartfox extension and it can call the database and create the new account.

Then if you switch back to the main screen, it logs the user out and then you can log back in under whatever account you just created. When you log in to the CreateAccount zone, this all happens behind the scenes and the client is never aware of any of this happening, it just looks like a new screen.

I think the problem I was having is I was connected, but there was no way to call any extensions because I was not logged into zone level.


Is this how you guys would approach this situation? Any ideas for changes / improvements are most welcomed. Thanks again.
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 27 Dec 2010, 07:31

Having 2 zones is also what I've done myself.

/Thomas
Fishypants
Posts: 57
Joined: 26 Oct 2010, 14:03
Location: South Pasadena California
Contact:

Postby Fishypants » 27 Dec 2010, 16:08

Having 2 zones is also what I've done myself.


Cool! Well as long as I am on a right track, I'm happy :D

Return to “.Net / Unity3D API”

Who is online

Users browsing this forum: No registered users and 3 guests