Page 1 of 1

SendXtMessage problem

Posted: 26 Apr 2009, 06:03
by duke
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!

Posted: 26 Apr 2009, 18:32
by ThomasLund
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

Posted: 26 Apr 2009, 23:22
by duke
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.

Posted: 27 Apr 2009, 07:36
by duke
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 :)

Posted: 27 Dec 2010, 00:14
by Fishypants
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?

Posted: 27 Dec 2010, 03:14
by Fishypants
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.

Posted: 27 Dec 2010, 07:31
by ThomasLund
Having 2 zones is also what I've done myself.

/Thomas

Posted: 27 Dec 2010, 16:08
by Fishypants
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