problems in connecting unity C# code to sfsextentions.as

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

Moderators: Lapo, Bax

venyboypalaboy
Posts: 7
Joined: 31 Mar 2009, 01:01
Contact:

problems in connecting unity C# code to sfsextentions.as

Postby venyboypalaboy » 03 Apr 2009, 02:27

Hi Good day to you. So what Happen is when i connect using the smartFox.SendXtMessage() method "in C# UNITY" it will always go to the function of HandleInternalEvent and trace("h2dbhandleinternalevent " + evt.toString()) in My extention actionscript in sfs then after that nothing happens. What should i do? what should i do to access the function handleRequest() so i can access the database.?

to further understand my problem try looking at the codes below.


This are the codes in c#

Code: Select all

   Hashtable paramss = new Hashtable();
            paramss["username1"] = username;
            paramss["password2"] = password;

smartFox.SendXtMessage("myext", "updData", paramss);


This are the code in Actionscript Extension

Code: Select all

// a global variable
var dbase

/*
* Initializion point:
*
* this function is called as soon as the extension
* is loaded in the server.
*
* You can add here all the initialization code
*
*/
function init()
{
   trace("Initing dbExtension")

   // get a reference to the database manager object
   // This will let you interact the database configure for this zone
   dbase = _server.getDatabaseManager()

}


function destroy()
{
   // Release the reference to the dbase manager
   delete dbase
}


function handleRequest(cmd, params, user, fromRoom)
{
   trace("h2dbhandrequest")
   
   if (cmd == cmd)//before (getList="1")
   {
      sendComputerList(user,cmd)
   }
}

function sendComputerList(user,cmd)
{
   
   var sql = "SELECT * FROM contacts where ID="+cmd+""
      
   // execute query on DB
   // queryRes is a ResultSet object
   var queryRes = dbase.executeQuery(sql)
   
   if (queryRes != null)
   {
      var response = {}
      
      response._cmd = cmd
      
      
      response.list = queryRes
      
      _server.sendResponse(response, -1, null, [user])
   }
}


/*
* This method handles internal events
* Internal events are dispactched by the Zone or Room where the extension is attached to
*
* the (evt) object
*/
function handleInternalEvent(evt)
{
   trace("h2dbhandleinternalevent " + evt.toString())
   // Code for handling events goes here...
}





Thanks in Advance..
:)
ill do things what they think i cant do.
User avatar
Lapo
Site Admin
Posts: 23026
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 03 Apr 2009, 13:49

Hi,
I've moved your post in the .Net section so that Thomas (our C# guru) can see it :)

Cheers.
Lapo
--
gotoAndPlay()
...addicted to flash games
venyboypalaboy
Posts: 7
Joined: 31 Mar 2009, 01:01
Contact:

Postby venyboypalaboy » 05 Apr 2009, 04:19

Thank you lapo..



-cheers!

:)
ill do things what they think i cant do.
ThomasLund
Posts: 1297
Joined: 14 Mar 2008, 07:52
Location: Sweden

Postby ThomasLund » 05 Apr 2009, 19:29

Been away for an extended weekend with the family, so didnt have time to reply.

Almost all (if not all) of my own extensions have been using internal events - and always java extensions.

So any help from me would right now be guesswork!

In java extensions, there are 3 different methods for "handleRequest" - one for each type of type (xml, json and string). So a guess would be that actionscript also has this, and you might not override the one that should be called.

You could try to use the 4 parameter version of the SendXtMessage method to precisely tell which message type you prefer.

I'm somewhat unsure how to help you specifically on this, and if its API related or server related.

Will try to look into some things on my end, but I ahve had no issues with extensions (in my use cases) or reports on them not working (in everyone elses). So my guess would be something in your extension code or how actionscript syntax works.

So I hope you can make some tests too and hopefully someone else can chime in too

In short - dont expect me to come up with anything within the next minutes :-) Its as new to me as for you, and with no reports claiming anything else I dont suspect it to be an issue in the API code for now (but definitely not saying that there is no bug in there either).

Best
Thomas

Return to “.Net / Unity3D API”

Who is online

Users browsing this forum: No registered users and 28 guests