experiencing a pretty weird behaviour with bigdbs successcallback for saving db objects.
First a code snippet, then further explanation:
- Code: Select all
player.myObj.Set("x", player.x);
player.myObj.Set("y", player.y);
player.myObj.Save(
delegate // success callback
{
player.Send("jump");
}
);
So far, so good.
Basically this code snippet saves the new positions that are assigned to the player by warping and then tells the client to disconnect from the server and connect to the new server it's been assigned to.
This is done with grace, and the new server then SHOULD load the coordinates that were assigned to the player, since the save already occured and has been successful.
But of course, the server prefers to give me a headache: The old coordinates are still being loaded, and hell, the new map that is assigned and loaded from the exact same db object is the map it's supposed to be. So the save occured, or...?
With that not enough, it sometimes works, sometimes not.
Each time it does not work, I get a neat null reference exception in my error log (from serverside), giving me the question: What could be null? I thought "It's obvious: The reference to "player" has been garbaged before the successcallback could execute!" and shortly after figured "omg, this cannot be, since the player does actually receive the message!".
So, this pretty much leaves me with a whole bunch of confusion and whatnot...
Any ideas? =/
And please save me the trouble with the easiest suggestion: The coordinates are assigned correct, I did use Console.WriteLine() and ErrorLog.WriteError() to verify this myself, and these are ALWAYS the correct ones, even if the code fails, also wrong set coordinates would in no way explain the null reference exception.
Best regards