Forum BigDB Some problems with loading data from BigDb on the server

Discussion and help relating to the PlayerIO database solution, BigDB.

Some problems with loading data from BigDb on the server

Postby L4ckyFox » February 9th, 2014, 1:21 am

I`ll want to load data from BigDB on the server for connected player and send to him. But received data on client is incorrect.
what am I doing wrong?
serverside code:
Code: Select all
public override void UserJoined(Player player)
        {
            var clientName = "";
            player.JoinData.TryGetValue("Name", out clientName);

            var recources = new Dictionary<string, int>();

            PlayerIO.BigDB.Load("Users",clientName,
                delegate(DatabaseObject databaseObject)
                    {
                       
                        var recourcesObject = databaseObject.GetObject("Recources");
                        // variables are declared
                        //
                        Aluminium = recourcesObject.GetInt("Aluminium"); // value in the database: 110
                        Titanium = recourcesObject.GetInt("Titanium"); // 20
                        Uranium = recourcesObject.GetInt("Uranium"); // 30
                        Hydrogen = recourcesObject.GetInt("Hydrogen"); // 40
                        Elix = recourcesObject.GetInt("Elix"); // 50
                        Credits = recourcesObject.GetInt("Credits"); // 11

                        recources.Add("Aluminium", Aluminium);
                        recources.Add("Titanium", Titanium);
                        recources.Add("Uranium", Uranium);
                        recources.Add("Hydrogen", Hydrogen);
                        recources.Add("Elix", Elix);
                        recources.Add("Credits", Credits);
                    });
            var m2 = Message.Create("m2", Aluminium, Titanium, Uranium, Hydrogen, Elix, Credits);
            player.Send(m2);
        }


received message on the client:
0
0
0
0
0
User avatar
L4ckyFox
 
Posts: 9
Joined: July 23rd, 2013, 1:28 pm
Location: Saint Petersburg

Re: Some problems with loading data from BigDb on the server

Postby L4ckyFox » February 10th, 2014, 1:47 am

reason for the error in this:
Code: Select all
            string clientName;
            player.JoinData.TryGetValue("Name", out clientName);

error log:
Webservice returned unhandled error: MissingValue


why player.JoinData.TryGetValue() is not working correctly ?
does the server supports multi-threaded programming? async, await ?
User avatar
L4ckyFox
 
Posts: 9
Joined: July 23rd, 2013, 1:28 pm
Location: Saint Petersburg

Re: Some problems with loading data from BigDb on the server

Postby L4ckyFox » February 22nd, 2014, 2:04 am

Somebody help! Please! When i`m downloading game library to site, ill see the message:
Invalid Game Dll: UPIO.Server.GameCode._cancellationTokenSource is of the non-allowed type: System.Threading.CancellationTokenSource

i`m using tasks on the server code.

Why it happens ? Server supports the Task ?
User avatar
L4ckyFox
 
Posts: 9
Joined: July 23rd, 2013, 1:28 pm
Location: Saint Petersburg

Re: Some problems with loading data from BigDb on the server

Postby Henrik » February 22nd, 2014, 2:59 am

L4ckyFox wrote:I`ll want to load data from BigDB on the server for connected player and send to him. But received data on client is incorrect.

The loaded object is returned to you in a callback (which executes on a different thread), but you send your message immediately after starting the load, not on completion. You need to send your message to the server inside the callback.
Henrik
.IO
 
Posts: 1880
Joined: January 4th, 2010, 1:53 pm

Re: Some problems with loading data from BigDb on the server

Postby Henrik » February 22nd, 2014, 3:02 am

L4ckyFox wrote:why player.JoinData.TryGetValue() is not working correctly ?

I don't think that error message is connected to you trying to retrieve the JoinData?

L4ckyFox wrote:does the server supports multi-threaded programming? async, await ?
Yes, all events coming in are multi-threaded by nature, and all your API calls return data in asynchronous callbacks.

If you want to schedule something at a later point, you can use the ScheduleCallback or AddTimer methods.
Henrik
.IO
 
Posts: 1880
Joined: January 4th, 2010, 1:53 pm

Re: Some problems with loading data from BigDb on the server

Postby Henrik » February 22nd, 2014, 3:03 am

L4ckyFox wrote:Somebody help! Please! When i`m downloading game library to site, ill see the message:
Invalid Game Dll: UPIO.Server.GameCode._cancellationTokenSource is of the non-allowed type: System.Threading.CancellationTokenSource

i`m using tasks on the server code.

Why it happens ? Server supports the Task ?

In your server-side code you are only allowed a subset of .Net features, and anything inside System.Threading is off-limits.
Henrik
.IO
 
Posts: 1880
Joined: January 4th, 2010, 1:53 pm


Return to BigDB



cron