I am trying to send a HighScore list from the MySQL DB to my clients.
On my Server AS Script
Code: Select all
if (cmd=="list"){
var mySql = "SELECT player.Nickname, player.Score FROM player ORDER BY player.Score DESC LIMIT 10"
var queryRes = dbase.executeQuery(mySql)
var response ={}
response._cmd="getList"
response.db = []
if (queryRes != null){
// Cycle through all records in the ResultSet
for (var i = 0; i < queryRes.size(); i++){
// Get a record
var tempRow = queryRes.get(i)
// This object will hold the record data that we'll send to the client
var item = {}
// From the record object we can get each field value
item.name = tempRow.getItem("Nickname")
item.score = tempRow.getItem("Score")
trace(item.name + " "+item.score)
response.db.push( item )
}
_server.sendResponse(response, fromRoom, null, [user])
}
On my Clients in Unity :
Code: Select all
void onExtensionResp(object dataObj, string type) {
if (type == SmartFoxClient.XTMSG_TYPE_XML)
{
SFSObject responseData = (SFSObject)dataObj;
if (responseData.GetString("_cmd")=="getList"){
// HERE is my problem, how do i get the array out of the Hashtable
}
}
How did i get the Array data out of my Hashtable ?
best regards
Zauri2000