Player.IO GameLibrary PlayerIO Publishing Network Access to the PlayerIO Publishing Network profiles Access to the users PlayerIO Publishing Network relations A UserToken that can be used to authenticate as the current user. Refresh Profiles and Relations. Callback that will be called when the refresh is complete. Refresh Profiles and Relations. Callback that will be called when the refresh is complete. Callback that will be called if the refresh fails. The PlayerIO Publishing Network profile service The profile of the current user Load a set of PlayerIO Publishing Network profiles The userIds of the profiles to load. Callback that will be called with the loaded profiles. Load a set of PlayerIO Publishing Network profiles The userIds of the profiles to load. Callback that will be called with the loaded profiles. Callback that will be called if the load fails. A PlayerIO Publishing Network profile The userId of the user The displayname of the user The url to the avatar of the user When was this user last seen The country code of the user The PlayerIO Publishing Network relations service List of all friends Check if a specific user is a friend The userId of the user to check. Check if a specific user is blocked The userId of the user to check. Inserts a cache entry into the cache by using a key and a value. A cache entry will never expire based on an absolute point in time, but it can be evicted from the cache by memory pressure in the server. Will always put a cache value in the cache, regardless whether an entry already exists with the same key. If the specified entry does not exist, a new cache entry is inserted. If the specified entry exists, it is updated. A unique identifier for the cache entry to insert. The data for the cache entry. Please note that you cannot store any PlayerIO objects with the only exception of DatabaseObject and DatabaseArray. Inserts a cache entry into the cache by using a key and a value. A cache entry will expire based on an absolute point in time, but it can be evicted before that from the cache by memory pressure in the server. Will always put a cache value in the cache, regardless whether an entry already exists with the same key. If the specified entry does not exist, a new cache entry is inserted. If the specified entry exists, it is updated. A unique identifier for the cache entry to insert. The data for the cache entry. Please note that you cannot store any PlayerIO objects with the only exception of DatabaseObject and DatabaseArray. The amount of time the cache should be kept in memory. Returns an entry from the cache. A unique identifier for the cache entry to get. A reference to the cache entry that is identified by key, if the entry exists; otherwise, null. Reads a value from cache. If value is available in the cache is called at once ( is not called in this case). If value is not available in cache is called. Inside load you need to call the delegate Action{System.Object} you receive as parameter when value is finally retrieved (you will likely retrieve value from an external asynchronous data source like BigDB or Web) At this point delegate will be called. It will receive the retrieved value as a parameter. If multiple calls to Get are received while the cache key is not available, delegate is guaranteed to be called only once. Each call to Get will have its delegate called when data is finally retrieved by your logic in delegate. This example loads a value from ServerCache if available. Otherwise it loads it from BigDB { public override void GameStarted() { ServerCache.Get("myKey", loaded => { //myKey was not found in ServerCache. Go and key value from outside source, in this case BigDB. PlayerIO.BigDB.LoadOrCreate("myTable", "myKey", dbObj => { //got value now. call loaded so it is stored in ServerCache and have 'done' delegate called (see below) loaded(dbObj); }, bigdbError => { //could not get value from BigDB. Call loaded(null) to clean resources loaded(null); }); }, TimeSpan.FromMinutes(30), cachedVal => { //got value! run logic that uses value. //no need to check for cachedVal != null since this callback will not be called in this case. //... }, error => { //this code will never be executed. would only execute if 'loaded' delegate is called with a value not allowed in ServerCache. //We called 'loaded' delegate with a DatabaseObject, which is allowed in ServerCache }); } } ]]> A unique identifier for the cache entry to get. This delegate is called if is not found in the cache. You need to provide code to load a value from an external source, i.e. BigDB or web resource. When you receive this value you need to call the parameter of type Action{System.Object} that you receive in will be called to permanently store value in cache/> Called at once if exists in cache or when it is finally retrieved via delegate Provides an extra param for . A unique identifier for the cache entry to get. This delegate is called if is not found in the cache. You need to provide code to load a value from an external source, i.e. BigDB or web resource. When you receive this value you need to call the parameter of type Action{System.Object} that you receive in will be called to permanently store value in cache/> Called at once if exists in cache or when it is finally retrieved via delegate Called if value retrieved from is not permitted in cache. See Provides an extra param for . A unique identifier for the cache entry to get. This delegate is called if is not found in the cache. You need to provide code to load a value from an external source, i.e. BigDB or web resource. When you receive this value you need to call the parameter of type Action{System.Object} that you receive in will be called to permanently store value in cache/> Use to call with the value retrieved from Called at once if exists in cache or when it is finally retrieved via delegate Called if value retrieved from is not permitted in cache. See Removes entry from cache. A unique identifier for the cache entry to get. A reference to the cache entry that is identified by key, if the entry exists; otherwise, null. The Player.IO Achievements service The list of all achievements; the values of Progress and ProgressGoal will indicate whether the achievement is started/pending/complete. Event fired whenever an achievement is completed by a call to ProgressXXX(). Add a handler to the OnComplete event This method gets the specified achievement The id of the achievement to get The achievement, if found, otherwise null. Refreshes MyAchievements Callback that will be called when the refresh is complete. Refreshes MyAchievements Callback that will be called when the refresh is complete. Callback that will be called instead of successCallback if an error occurs. Load achivements for the specified users. Array of userIds to load achivements for. Callback that will be called with a dictionary where the keys are userIds and the values are their achievments. Load achivements for the specified users. Array of userIds to load achivements for. Callback that will be called with a dictionary where the keys are userIds and the values are their achievments. Callback that will be called instead of successCallback if an error occurs. Sets the progress of the specified achievement. The id of the achievement to add progress to. The new progress value for the achievement. Callback that will be called with the updated Achievement. Sets the progress of the specified achievement. The id of the achivement to add progress to. The new progress value for the achievement. Callback that will be called with the updated Achievement. Callback that will be called instead of successCallback if an error occurs. Add or subtract from the current progress of an achievement. The id of the achievement to add progress to. The delta value that will be added to the current progress of the achievement. Callback that will be called with the updated Achievement. Add or subtract from the current progress of an achievement. The id of the achivement to add progress to. The delta value that will be added to the current progress of the achievement. Callback that will be called with the updated Achievement. Callback that will be called instead of successCallback if an error occurs. Sets the current progress value to the bigger value of progress or the current value, i.e; newProgress = Max(currentProgress,progress) The id of the achievement to work on. The possible new progress value that should be compared to the current progress value Callback that will be called with the updated Achievement. Sets the current progress value to the bigger value of progress or the current value, i.e; newProgress = Max(currentProgress,progress) The id of the achivement to work on. The possible new progress value that should be compared to the current progress value Callback that will be called with the updated Achievement. Callback that will be called instead of successCallback if an error occurs. Complete the specified achievement, by setting the progress to the maximum (ProgressGoal) of the achievement. The id of the achievement to complete. Callback that will be called with the updated Achievement. Complete the specified achievement, by setting the progress to the maximum (ProgressGoal) of the achievement. The id of the achivement to complete. Callback that will be called with the updated Achievement. Callback that will be called instead of successCallback if an error occurs. An Achievement The id of the achievement The title of the achievement The description A url to the image of the achievement Current progress made towards the ProgressGoal of this achievement The progress value to reach to complete the achievement Last updated time, in UTC A value in the range [0:1] indicating the progress made towards completion. True when Progress==ProgressGoal The Player.IO BigDB service. This class is used to create, load, and delete database objects. All database objects are stored in tables and have a unique key. You can set up tables in your admin panel, and you can also set up indexes there for when you want to load objects by properties or ranges of properties. Please note that all methods are asynchronous and any handling of results have to be done in a callback. If you don't care about the results of a method call, typically for create or delete functions, you can just pass in a null callback. Here's how to store and update an object: //Make new object and set some properties DatabaseObject obj = new DatabaseObject(); obj.Set("username", "Adam"); obj.Set("location", "London"); obj.Set("age", 20); //Create object in table Users with ConnectUserId as key PlayerIO.BigDB.CreateObject("Users", ConnectUserId, obj, delegate (DatabaseObject result){ //Change a property and store the update when created result.Set("location", "Paris"); result.Save(null); } ); This is how you load an object: PlayerIO.BigDB.Load("Users", ConnectUserId, delegate (DatabaseObject result){ if (result != null) { //Change a property and save back. result.Set("location", "Amsterdam"); result.Save(null); } }); In case you always want to modify an object, you can use the LoadOrCreate method to ensure you get an object back: PlayerIO.BigDB.LoadOrCreate("Users", ConnectUserId, delegate (DatabaseObject result){ if (!result.Contains("username")) { //Empty object, initialize it result.Set("username", "Charlie"); result.Set("age", 20); } result.Set("location", "London"); result.Save(); } ); BigDB also supports indexes for retrieving objects by a specific property, a range of properties, or to sort objects by properties. Indexes need to be set up in the admin panel for each table, each index needs a name, and a list of properties, and for each property you also need to specify a sort order. Imagine that we have objects that look like this: { username:"Adam", created:2010-05-12 15:28 location:"London", age:20, } That we have defined an index called "ByUsername" that looks like this:
  • {Property:"username", Type:String, Order:Ascending}
And an index called "ByCreated" that looks like this:
  • {Property:"created", Type:Datetime, Order:Descending}
Then we can do lookups like these: //Get the object where username="Adam" PlayerIO.BigDB.LoadSingle("Users", "ByUsername", new object[]{"Adam"}, delegate(DatabaseObject result) { //... } ); //Get all users with usernames between "Adam" and "Charlie". //This would retrieve users named "Adamsson" and "Barney", //but not users named "Abel" or "Charlotte". PlayerIO.BigDB.LoadRange("Users", "ByUsername", null, "Adam", "Charlie", 100, delegate(DatabaseObject[] result) { //... } ); //Get all users up to and including "Adam". This would retrieve //users named "Aaron" and "Ackerman", but not "Adamsson" or "Barney". PlayerIO.BigDB.LoadRange("Users", "ByUsername", null, null, "Adam", 100, delegate(DatabaseObject[] result) { //... } ); //Get all users from "Xerxes". This would retrieve users named //"Yngwie" and "Zed", but not "Charlie" or "Xantippa". PlayerIO.BigDB.LoadRange("Users", "ByUsername", null, "Xerxes", null, 100, delegate(DatabaseObject[] result) { //... } ); //Retrieve the ten first objects by the ByCreated index. //Since that index is sorted in descending order, this will actually //retrieve the 10 latest created users. PlayerIO.BigDB.LoadRange("Users", "ByCreated", null, null, null, 10, delegate(DatabaseObject[] result) { //... } ); //Get the 10 latest users that were created more than 7 days ago. var weekago = DateTime.Now.AddDays(-7); PlayerIO.BigDB.LoadRange("Users", "ByCreated", null, weekago, null, 10, delegate(DatabaseObject[] result) { //... } ); BigDB also supports compound indexes, that is indexes with more than one property. Given our example object above, we can create an index called "ByLocationAgeCreated" that looks like this:
  • {Property:"location", Type:String, Order:Ascending}
  • {Property:"age", Type:Integer, Order:Ascending}
  • {Property:"created", Type:Datetime, Order:Descending}
With this index, we can then lookup on either location, or location and age, or location and age and created. If we use more than one property in the lookup, we can only specify the range for the last one, the preceding ones have to be fixed and are sent in via the path parameter. //Load all users where location is "London" PlayerIO.BigDB.LoadRange("Users", "ByLocationAgeCreated", null, "London", "London", 100, delegate(DatabaseObject[] result) { //... } ); //Load all users from London between 20 and 30 years of age PlayerIO.BigDB.LoadRange("Users", "ByLocationAgeCreated", new object[]{"London"}, 20, 30, 100, delegate(DatabaseObject[] result) { //... } ); //Load all users from London that are above 50 PlayerIO.BigDB.LoadRange("Users", "ByLocationAgeCreated", new object[]{"London"}, 50, null, 100, delegate(DatabaseObject[] result) { //... } ); //Load all users from Paris that are 30 years old, and were created in April PlayerIO.BigDB.LoadRange("Users", "ByLocationAgeCreated", new object[]{"Paris", 30}, new DateTime(2010, 4, 1), new DateTime(2010, 4, 30), 100, delegate(DatabaseObject[] result) { //... } ); //Load the 10 latest 20-year old users from Amsterdam PlayerIO.BigDB.LoadRange("Users", "ByLocationAgeCreated", new object[]{"Amsterdam", 20}, null, null, 10, delegate(DatabaseObject[] result) { //... } ); Finally, deleting objects is as easy as calling the DeleteKeys method, or DeleteRange if you want to delete by an index. //Delete current Users object. PlayerIO.BigDB.DeleteKeys("Users", ConnectUserId, null); //Delete all objects with usernames between "Adam" and "Charle" PlayerIO.BigDB.DeleteRange("Users", "ByUsername", null, "Adam", "Charlie", null); //Delete all objects with created older than one year PlayerIO.BigDB.DeleteRange("Users", "ByUsername", null, DateTime.Now.AddYear(-1), null, null);
Creates a new database object in the given table with the specified key. If no key is specified (null), the object will receive an autogenerated id. The name of the table to create the database object in The key to assign to the database object The database object to create in the table Callback to execute when the object has been created with a new instance of DatabaseObject from which .Save() can be called for future modifications. Creates a new database object in the given table with the specified key. If no key is specified (null), the object will receive an autogenerated id. The name of the table to create the database object in The key to assign to the database object The database object to create in the table Callback that will be called with a new instance of DatabaseObject from which .Save() can be called for future modifications when the object has been created. Callback that will be called instead of successCallback if an error occurs during the object creation. Load the database object with the given key from the given table. The table to load the database object from The key of the database object to load Callback with the loaded database object Load the database object with the given key from the given table. The table to load the database object from The key of the database object to load Callback with the loaded database object or null if no object exists with the given key Callback that will be called instead of successCallback if an error occurs during the load. Loads or creates the database object with the given key from the given table. The table from which to load or create the database object The key of the database object to load or create Callback with the database object Loads or creates the database object with the given key from the given table. The table from which to load or create the database object The key of the database object to load or create Callback with the database object Callback that will be called instead of successCallback if an error occurs during the load or create. Loads the database objects with the given keys from the given table. The table to load the database objects from They keys of the database objects to load Callback with an array of database objects in the same order as the keys array, with null values for non-existant database objects Loads the database objects with the given keys from the given table. The table to load the database objects from They keys of the database objects to load Callback with an array of database objects in the same order as the keys array, with null values for non-existant database objects Callback that will be called instead of successCallback if an error occurs during the load. Loads or creates database objects with the given keys from the given table. New objects are created if there are no existing objects for the given keys. The table to load the database objects from They keys of the database objects to load Callback with an array of database objects in the same order as the keys array Loads or creates database objects with the given keys from the given table. New objects are created if there are no existing objects for the given keys. The table to load the database objects from They keys of the database objects to load Callback with an array of database objects in the same order as the keys array Callback that will be called instead of successCallback if an error occurs during the load or create. Load a database object from a table using the specified index. The table to load the database object from The name of the index to query for the database object An array of objects of the same types as the index properties, specifying which object to load Callback with the database object found, or null if no object was found Load a database object from a table using the specified index. The table to load the database object from The name of the index to query for the database object An array of objects of the same types as the index properties, specifying which object to load Callback with the database object found, or null if no object was found Callback that will be called instead of successCallback if an error occurs during the load. Load a range of database objects from a table using the specified index. The table to load the database object from The name of the index to query for the database object Where in the index to start the range search: An array of objects of the same types as the index properties, specifying where in the index to start loading database objects from. For instance, in the index [Mode,Map,Score] you might use new object[]{"expert","skyland"} as the indexPath and use the start and stop arguments to determine the range of scores you wish to return. IndexPath can be set to null if there is only one property in the index. Where to start the range search. For instance, if the index is [Mode,Map,Score] and indexPath is ["expert","skyland"], then start defines the minimum score to include in the results Where to stop the range search. For instance, if the index is [Mode,Map,Score] and indexPath is ["expert","skyland"], then stop defines the maximum score to include in the results The max amount of objects to return Callback with the database objects found. Load a range of database objects from a table using the specified index. The table to load the database object from The name of the index to query for the database object Where in the index to start the range search: An array of objects of the same types as the index properties, specifying where in the index to start loading database objects from. For instance, in the index [Mode,Map,Score] you might use new object[]{"expert","skyland"} as the indexPath and use the start and stop arguments to determine the range of scores you wish to return. IndexPath can be set to null if there is only one property in the index. Where to start the range search. For instance, if the index is [Mode,Map,Score] and indexPath is ["expert","skyland"], then start defines the minimum score to include in the results Where to stop the range search. For instance, if the index is [Mode,Map,Score] and indexPath is ["expert","skyland"], then stop defines the maximum score to include in the results The max amount of objects to return Callback with the database objects found. Callback that will be called instead of successCallback if an error occurs during the load. Save changes to one or more database objects in one go. Should the save only go through, if no other process has modified the object since it was loaded? Overwrite the stored object with the data from this object instead of only sending in the changed properties The objects with changes to save Callback with true if the save succeded and false if it failed (only if using optimistic locking and newer version exists in database) Save changes to one or more database objects in one go. Should the save only go through, if no other process has modified the object since it was loaded? Overwrite the stored object with the data from this object instead of only sending in the changed properties The objects with changes to save Callback with true if the save succeded and false if it failed (only if using optimistic locking and newer version exists in database) Callback that will be called instead of successCallback if an error occurs during the save. Delete a set of database objects from a table The table to delete the database objects from The keys of the database objects to delete Delete a set of database objects from a table The table to delete the database objects from The keys of the database objects to delete Callback when the deletion has completed. Delete a set of database objects from a table The table to delete the database objects from The keys of the database objects to delete Callback when the deletion has completed. Callback that will be called instead of successCallback if an error occurs during the deletion. Delete a range of database objects from a table using an index The table to delete the database object from The name of the index to query for the database objects to delete Where in the index to start the range delete: An array of objects of the same types as the index properties, specifying where in the index to start loading database objects from. For instance, in the index [Mode,Map,Score] you might use new object[]{"expert","skyland"} as the indexPath and use the start and stop arguments to determine the range of scores you wish to delete. IndexPath can be set to null instead of an empty array. Where to start the range delete. For instance, if the index is [Mode,Map,Score] and indexPath is ["expert","skyland"], then start defines the minimum score to delete Where to stop the range delete. For instance, if the index is [Mode,Map,Score] and indexPath is ["expert","skyland"], then stop defines the maximum score to delete Delete a range of database objects from a table using an index The table to delete the database object from The name of the index to query for the database objects to delete Where in the index to start the range delete: An array of objects of the same types as the index properties, specifying where in the index to start loading database objects from. For instance, in the index [Mode,Map,Score] you might use new object[]{"expert","skyland"} as the indexPath and use the start and stop arguments to determine the range of scores you wish to delete. IndexPath can be set to null instead of an empty array. Where to start the range delete. For instance, if the index is [Mode,Map,Score] and indexPath is ["expert","skyland"], then start defines the minimum score to delete Where to stop the range delete. For instance, if the index is [Mode,Map,Score] and indexPath is ["expert","skyland"], then stop defines the maximum score to delete Callback when the deletion has completed. Delete a range of database objects from a table using an index The table to delete the database object from The name of the index to query for the database objects to delete Where in the index to start the range delete: An array of objects of the same types as the index properties, specifying where in the index to start loading database objects from. For instance, in the index [Mode,Map,Score] you might use new object[]{"expert","skyland"} as the indexPath and use the start and stop arguments to determine the range of scores you wish to delete. IndexPath can be set to null instead of an empty array. Where to start the range delete. For instance, if the index is [Mode,Map,Score] and indexPath is ["expert","skyland"], then start defines the minimum score to delete Where to stop the range delete. For instance, if the index is [Mode,Map,Score] and indexPath is ["expert","skyland"], then stop defines the maximum score to delete Callback when the deletion has completed. Callback that will be called instead of successCallback if an error occurs during the deletion. Represents an BigDB array of values that can be accessed by index. DatabaseArray is very similar to the DatabaseObject class since it has methods for getting, setting, checking and removing values. But unlike DatabaseObject, this class also has methods for adding and inserting values, and there is no Save method, since these cannot be saved to a BigDB table, they always have to be a property of an object. If we for example have an object that can be visualized like this: 'car54321' = { Name: 'OldSpeedy', LatestLapTimes: [ { Time:'20:34', Position:1 }, { Time:'22:03', Position:4 }, { Time:'22:30', Position:5 } ] } Then we would create it in BigDB like this: //Create new object DatabaseObject car = new DatabaseObject(); car.Set("Name", "OldSpeedy"); //Make laptimes DatabaseObject laptime1 = new DatabaseObject(); laptime1.Set("Time", "20:34"); laptime1.Set("Position", 1); DatabaseObject laptime2 = new DatabaseObject(); laptime2.Set("Time", "22:03"); laptime2.Set("Position", 4); DatabaseObject laptime3 = new DatabaseObject(); laptime3.Set("Time", "22:30"); laptime3.Set("Position", 5); //Make array and add laptimes DatabaseArray laptimes = new DatabaseArray(); laptimes.Add(laptime1); laptimes.Add(laptime2); laptimes.Add(laptime3); //Add array to car object car.Set("LatestLapTimes", laptimes); //Save car to table "Cars" under key "car54321" PlayerIO.BigDB.CreateObject("Cars", "car54321", car, null); However, just like DatabaseObject, DatabaseArray also supports nested property names, and we can refer to values in the array with their index number. Using this, we can make the example object in an easier way, like this: DatabaseObject car = new DatabaseObject(); car.Set("Name", "OldSpeedy"); car.Set("LatestLapTimes", new DatabaseArray()); car.Set("LatestLapTimes.0.Time", "20:34"); car.Set("LatestLapTimes.0.Position", 1); car.Set("LatestLapTimes.1.Time", "22:03"); car.Set("LatestLapTimes.1.Position", 4); car.Set("LatestLapTimes.2.Time", "22:30"); car.Set("LatestLapTimes.2.Position", 5); Getting values works exactly like for DatabaseObject, and we can also use nested properties. PlayerIO.BigDB.Load("Cars", "car54321", delegate(DatabaseObject car) { //Get position from first laptime DatabaseArray laptimes = car.GetArray("LatestLapTimes"); DatabaseObject laptime = laptimes.GetObject(0); int position = laptime.GetInt("Position"); //Get position from second laptime int position2 = laptimes.GetInt("1.Position"); //Or get position from third laptime directly int position3 = car.GetInt("LatestLapTimes.2.Position"); }); In addition to getting and setting values, we can also add values to the end of the array, insert values in the middle of it, or remove values in the middle of it. Note that the arrays are sparse, this means that removing a value doesn't shift the indexes of the following values, and we can set any value beyond the last value of the array. DatabaseArray arr = new DatabaseArray(); //We make an array like this: ['a', 'c'] arr.Add("a"); arr.Add("c"); //Now it will look like this: ['a', 'c', 'd'] arr.Add("d"); //We insert a value where c is to get this: ['a', 'b', 'c', 'd'] arr.Insert(1, "b"); //If we then remove the third value we get this: ['a', 'b', null, 'd'] arr.RemoveAt(2); //Finally, we set the sixth value and get: ['a', 'b', null, 'd', null, 'f'] arr.Set(5, "f"); DatabaseArray constructor Returns the number of values in this array. If set to a smaller number than the current count, it will truncate the array. Remove all values from this array Remove the value at the given index Get the value at the given index as an object Returns an enumerator that iterates over the indexes in this array that contain values. Returns an enumerator that iterates over all the indexes and values in this array. Returns true if a value exists at the given index Get the value at the given index as an object Get the string value at the given index Get the string value at the given index, falling back to the given default value if the value was at the index is null Get the int value at the given index Get the int value at the given index, falling back to the given default value if the value was at the index is null Get the uint value at the given index Get the uint value at the given index, falling back to the given default value if the value was at the index is null Get the long value at the given index Get the long value at the given index, falling back to the given default value if the value was at the index is null Get the bool value at the given index Get the bool value at the given index, falling back to the given default value if the value was at the index is null Get the float value at the given index Get the float value at the given index, falling back to the given default value if the value was at the index is null Get the double value at the given index Get the double value at the given index, falling back to the given default value if the value was at the index is null Get the byte array value at the given index Get the byte value at the given index, falling back to the given default value if the value was at the index is null Get the datetime value at the given index Get the datetime value at the given index, falling back to the given default value if the value was at the index is null Get the object at the given index Get the array at the given index Set the value at the given index to the given string Set the value at the given index to the given int Set the value at the given index to the given uint Set the value at the given index to the given long Set the value at the given index to the given bool Set the value at the given index to the given float Set the value at the given index to the given double Set the value at the given index to the given byte array Set the value at the given index to the given datetime Set the value at the given index to the given object Set the value at the given index to the given array Insert the given string value at the given index Insert the given int value at the given index Insert the given uint value at the given index Insert the given long value at the given index Insert the given bool value at the given index Insert the given float value at the given index Insert the given double value at the given index Insert the given byte array value at the given index Insert the given datetime value at the given index Insert the given object at the given index Insert the given array at the given index Add the given string value to the array Add the given int value to the array Add the given uint value to the array Add the given long value to the array Add the given bool value to the array Add the given float value to the array Add the given double value to the array Add the given byte array value to the array Add the given datetime value to the array Add the given object to the array Add the given array to the array Removes the value of the given property from this object Returns true if the given property exists on this object If the given property exists, this method returns true and the value as object in the out parameter. If it does not, this method return false Get the given property as an object Get the given string property Get the given string property, falling back to the given default value if the string property does not exist Get the given int property Get the given int property, falling back to the given default value if the int property does not exist Get the given uint property Get the given uint property, falling back to the given default value if the uint property does not exist Get the given long property Get the given long property, falling back to the given default value if the long property does not exist Get the given bool property Get the given bool property, falling back to the given default value if the bool property does not exist Get the given float property Get the given float property, falling back to the given default value if the float property does not exist Get the given double property Get the given double property, falling back to the given default value if the double property does not exist Get the given byte array property Get the given byte array property, falling back to the given default value if the byte array property does not exist Get the given datetime property Get the given datetime property, falling back to the given default value if the datetime property does not exist Get the given object property Get the given array property Set the given property to the given string value Set the given property to the given int value Set the given property to the given uint value Set the given property to the given long value Set the given property to the given bool value Set the given property to the given float value Set the given property to the given double value Set the given property to the given byte array value Set the given property to the given datetime value Set the given property to the given object Set the given property to the given array This class represents a BigDB Database Object that has a Key and a collection of named properties. There are methods for setting, getting, and removing properties, and changes to the object can be persisted to BigDB with the Save() method. Database objects are very similar to JSON objects and are most easily visualized as such. For example, we can visualize a car object like this: 'car20312' = { Name: 'OldSpeedy', Stats:{ Acceleration: 3.2, TopSpeed: 50, Steering: 5, WorkingBreaks:false } LatestLapTimes: ['20:34','22:03','22:30'] } If we then want to create this object in BigDB, we would have to do this: DatabaseObject car = new DatabaseObject(); car.Set("Name", "OldSpeedy"); //Create nested stats object DatabaseObject stats = new DatabaseObject(); stats.Set("Acceleration", 3.2); stats.Set("TopSpeed", 50); stats.Set("Steering", 5); stats.Set("WorkingBreaks", false); car.Set("Stats", stats); //Create laptimes array DatabaseArray laptimes = new DatabaseArray(); laptimes.Add("20:34"); laptimes.Add("22:03"); laptimes.Add("22:30"); car.Set("LatestLapTimes", laptimes); //Save car to table "Cars" under key "car20312" PlayerIO.BigDB.CreateObject("Cars", "car20312", car, null); To make it easier to work with nested objects, you can reference them directly by separating the property names with a dot. Using this, we can set the stats properties of the car like this instead: DatabaseObject car = new DatabaseObject(); car.Set("Stats.Acceleration", 3.2); car.Set("Stats.TopSpeed", 50); car.Set("Stats.Steering", 5); car.Set("Stats.WorkingBreaks", false); When you want to read properties from a database object, you have to call the corresponding get method indicating the type of the property. PlayerIO.BigDB.Load("Cars", "car20312", delegate(DatabaseObject car) { string name = car.GetString("Name"); float acceleration = car.GetFloat("Stats.Acceleration"); int topspeed = car.GetInt("Stats.TopSpeed"); }); BigDB doesn't enforce anything on your objects. Two objects in the same table do not need to have the same properties set, and do not need to have the same type on the same property. If you try to get a property that is missing, or if you are using a get method of the wrong type, you will get an exception. PlayerIO.BigDB.Load("Cars", "car20312", delegate(DatabaseObject car) { //Name is a string, throws exception! int name = car.GetInt("Name"); //Color does not exist, throws exception! string color = car.GetString("Color"); }); One way of avoiding this is to first check the object if a certain property exists before reading this. You can do this with the Contains method. PlayerIO.BigDB.Load("Cars", "car20312", delegate(DatabaseObject car) { if (!car.Contains("Name")) { car.Set("Name", "Unknown"); } if (car.Contains("Stats.Steering")) { //... } }); Another way of avoiding errors is to specify a default value when calling a get method. If the object doesn't contain the property, the method will return your default value instead. PlayerIO.BigDB.Load("Cars", "car20312", delegate(DatabaseObject car) { string color = car.GetString("Color", "Red"); }); You can also easily remove properties from your object with the Remove method. PlayerIO.BigDB.Load("Cars", "car20312", delegate(DatabaseObject car) { car.Remove("Name"); car.Remove("Stats.TopSpeed"); if (!car.Contains("Name")) { //Name property should be removed now. } }); Finally, to persist any changes you've made to an object you can call the Save method. Note that you can only call Save on an object that exist in the database. This means that the first time you save an object you have to call the PlayerIO.BigDB.CreateObject method, but all subsequent times you can call the Save method. There is also a property called ExistsInDatabase that you can use to check if it has been created or not. car.Set("Name", "NewSpeedy"); car.Set("Stats.Acceleration", 5.0); if (car.ExistsInDatabase) { car.Save(); } else { PlayerIO.BigDB.CreateObject("Cars", "car12345", null); } The Save method is asynchronous just like the CreateObject method in PlayerIO.BigDB, and you can specify a callback if you wish to do something when the object actually has been saved. car.Set("Name", "NewSpeedy"); car.Set("Stats.Acceleration", 5.0); car.Save(delegate() { //On successful save... }); Returns true if the object has been persisted The name of the BigDB table this object belongs to The key of the object. Persist the object to the database asynchronously.

If use the overloads with success callbacks if you need to know when the save has completed successfully

Persist the object to the database asynchronously, using optimistic locking if specified

If use the overloads with success callbacks if you need to know when the save has completed successfully

If true, the save will only be completed if the database object has not changed in BigDB since this instance was loaded.
Persist the object to the database asynchronously, using optimistic locking and full overwrite if specified

If use the overloads with success callbacks if you need to know when the save has completed successfully

If true, the save will only be completed if the database object has not changed in BigDB since this instance was loaded. Will completely overwrite the database object in BigDB with the properties in this instance, instead of just sending the changed properties to the server.
Persist the object to the database Callback when the save succeeds Persist the object to the database Callback when the save succeeds Callback that will be called instead of successCallback if an error occurs during the save. Persist the object to the database, using optimistic locking if specified If true, the save will only be completed if the database object has not changed in BigDB since this instance was loaded. Callback when the save succeeds Persist the object to the database, using optimistic locking if specified If true, the save will only be completed if the database object has not changed in BigDB since this instance was loaded. Callback when the save succeeds Callback that will be called instead of successCallback if an error occurs during the save. Persist the object to the database, using optimistic locking and full overwrite if specified If true, the save will only be completed if the database object has not changed in BigDB since this instance was loaded. Will completely overwrite the database object in BigDB with the properties in this instance, instead of just sending the changed properties to the server. Callback when the save succeeds Persist the object to the database, using optimistic locking and full overwrite if specified If true, the save will only be completed if the database object has not changed in BigDB since this instance was loaded. Will completely overwrite the database object in BigDB with the properties in this instance, instead of just sending the changed properties to the server. Callback when the save succeeds Callback that will be called instead of successCallback if an error occurs during the save. DatabaseObject constructor Returns the number of properties on this object Get the given property as an object Get the names of all properties on this object Removes all properties on this object Removes the value of the given property from this object Returns true if the given property exists on this object If the given property exists, this method returns true and the value as object in the out parameter. If it does not, this method return false Get the given property as an object Get the given string property Get the given string property, falling back to the given default value if the string property does not exist Get the given int property Get the given int property, falling back to the given default value if the int property does not exist Get the given uint property Get the given uint property, falling back to the given default value if the uint property does not exist Get the given long property Get the given long property, falling back to the given default value if the long property does not exist Get the given bool property Get the given bool property, falling back to the given default value if the bool property does not exist Get the given float property Get the given float property, falling back to the given default value if the float property does not exist Get the given double property Get the given double property, falling back to the given default value if the double property does not exist Get the given byte array property Get the given byte array property, falling back to the given default value if the byte array property does not exist Get the given datetime property Get the given datetime property, falling back to the given default value if the datetime property does not exist Get the given object property Get the given array property Set the given property to the given string value Set the given property to the given int value Set the given property to the given uint value Set the given property to the given long value Set the given property to the given bool value Set the given property to the given float value Set the given property to the given double value Set the given property to the given byte array value Set the given property to the given datetime value Set the given property to the given object Set the given property to the given array The Player.IO GameFS Service Here is a simple example on how to use GameFS: string assetUrl = PlayerIO.GameFS.GetUrl("/assets/image.png"); Converts a GameFS path (like '/mygame.swf') into a full url, that can be downloaded over the internet. Important! Do not save or otherwise persist (bigdb, cookies, etc) the returned url, since the url will change over time. The path of the file in the GameFS, including the initial slash. Examples: '/mygame.swf' or '/characters/bob.jpg' An url that can be used to download the resource over the internet Converts a GameFS path (like '/mygame.swf') into a full url, that can be downloaded over the internet. Important! Do not save or otherwise persist (bigdb, cookies, etc) the returned url, since the url will change over time. The path of the file in the GameFS, including the initial slash. Examples: '/mygame.swf' or '/characters/bob.jpg' If true, this method returns a secure (https) url. An url that can be used to download the resource over the internet The Player.IO GameRequests service The list of oldest received requests that are waiting to be processed and deleted. Send a GameRequest to the specified recipients The request type of the request to send. Data that will be available to the recipient of the request with information about the request. Useful for passing any kind of data to the recipient. The recipients to send this request to. Callback that will be called when the operation succeeds. Send a GameRequest to the specified recipients The request type of the request to send. Data that will be available to the recipient of the request with information about the request. Useful for passing any kind of data to the recipient. The recipients to send this request to. Callback that will be called when the operation succeeds. Callback that will be called instead of successCallback if an error occurs during the operation. Refresh the list of received requests. Callback that will be called when the operation succeeds. Refresh the list of received requests. Callback that will be called when the operation succeeds. Callback that will be called instead of successCallback if an error occurs during the operation. Delete the given requests. Will also update the WaitingRequests property after deletion is complete. The list of requests to delete. Callback that will be called when the operation succeeds. Delete the given requests. Will also update the WaitingRequests property after deletion is complete. The list of requests to delete. Callback that will be called when the operation succeeds. Callback that will be called instead of successCallback if an error occurs during the operation. A received game request The request type of the request The user id of the user that sent the request When the request was received The game-specific extra data associated with this request The Player.IO Notifications service The list of notification endpoints registered for the current client. Refreshes MyEndpoints Callback that will be called when the refresh is complete. Refreshes MyEndpoints Callback that will be called when the refresh is complete. Callback that will be called instead of successCallback if an error occurs. Register a device or endpoint with Player.IO. Endpoint type, such as, IOS, Android, email, etc. The identifier of the endpoint, such as the device token on iOS or an email address for email. Configuration relating to the endpoint. Can be null. Should the endpoint be enabled. Callback that is invoked when operation succeeds Register a device or endpoint with Player.IO. Endpoint type, such as, IOS, Android, email, etc. The identifier of the endpoint, such as the device token on iOS or an email address for email. Configuration relating to the endpoint. Can be null. Should the endpoint be enabled. Callback that is invoked when operation succeeds Callback that is invoked when operation fails Send one or more notifications The notifications to send Callback that is invoked when operation succeeds Send one or more notifications The notifications to send Callback that is invoked when operation succeeds Callback that is invoked when operation fails Enables or disabled the given endpoints. The endpoints to enable or disable. If true, all the given endpoints will be enabled. If false, they'll be disabled. Callback that is invoked when operation succeeds Enables or disabled the given endpoints. The endpoints to enable or disable. If true, all the given endpoints will be enabled. If false, they'll be disabled. Callback that is invoked when operation succeeds Callback that is invoked when operation fails Deletes the given endpoints The endpoints to delete. Callback that is invoked when operation succeeds Deletes the given endpoints The endpoints to delete. Callback that is invoked when operation succeeds Callback that is invoked when operation fails Notifications Endpoint The type of the endpoint The endpoint identifier (e.g, push device id or e-mail address...) The configuration of the endpoint Is this endpoint currently enabled? A Notification The intended recipient (userId) of this notification The type of notification endpoint that will receive this notification The notification data Create a new notification intended for the specified recipient if he/she has registered a notification endpoint of the given type. The intended recipient userId of this notification. The endpoint type that this notification is intended for. Add a specific argument to the Data of this notification The key to add The value to add This instance for chainable calls to Set() The Player.IO OneScore service OneScore value The percentile compared to all other players. A value from 0 -> 100. A value of 30.0 means you are in the bottom 30% of players. A value of 100 means you are in the top 100% with other players. The absolute ranking number -- if you are one of the N top players, then it returns N. 1 means you are the best. Returns 0 if you are not one the top N players. (N is currently 1000.) Refresh OneScore for the user. Callback that will be called when the operation succeeds. Refresh OneScore for the user. Callback that will be called when the operation succeeds. Callback that will be called instead of successCallback if an error occurs during the operation. Sets OneScore for the user. The score to set for the user. Callback that will be called when the operation succeeds. Sets OneScore for the user. The score to set for the user. Callback that will be called when the operation succeeds. Callback that will be called instead of successCallback if an error occurs during the operation. Adds the score to the OneScore for the user. The score to add for the user. Callback that will be called when the operation succeeds. Adds the score to the OneScore for the user. The score to add for the user. Callback that will be called when the operation succeeds. Callback that will be called instead of successCallback if an error occurs during the operation. Loads OneScore for multiple users. The user ids to load OneScore for. Callback that will be called when the operation succeeds. Contains the loaded list of OneScores. Loads OneScore for multiple users. The user ids to load OneScore for. Callback that will be called when the operation succeeds. Contains the loaded list of OneScores. Callback that will be called instead of successCallback if an error occurs during the operation. OneScore value and Percentile The score The percentile compared to all other players. A value from 0 -> 100. A value of 30.0 means you are in the bottom 30% of players. A value of 100 means you are in the top 100% with other players. The absolute ranking number -- if you are one of the N top players, then it returns N. 1 means you are the best. Returns 0 if you are not one the top N players. (N is currently 1000.) DEPRECATED. DO NOT USE. DEPRECATED. DO NOT USE. DEPRECATED. DO NOT USE. DEPRECATED. DO NOT USE. DEPRECATED. DO NOT USE. DEPRECATED. DO NOT USE. DEPRECATED. DO NOT USE. DEPRECATED. DO NOT USE. DEPRECATED. DO NOT USE. DEPRECATED. DO NOT USE. The Player.IO PayVault. Instances of this class represent a specific user's Vault, and contains methods and properties both for inspecting and manipulating the contents. If you have a BasePlayer object, you can access that user's Vault directly: PayVault vault = player.PayVault; You can also access the Vault of any other user that isn't connected to your specific multiplayer room, by calling the GetUserPayVault() method: PayVault vault = PlayerIO.GetUserPayVault("connectUserId"); All properties and methods that inspect the Vault requires that it is up-to-date first. This can be achieved explicitly by calling the Refresh() method or implicitly by calling any method which modifies the Vault. Here is how to read the Coins balance: PayVault vault = player.PayVault; vault.Refresh(delegate(){ int coins = vault.Coins; }); This is how you check if an item exists: PayVault vault = player.PayVault; vault.Refresh(delegate(){ if (vault.Has("simplecar")) { //... } }); Credit and Debit can be used like this: PayVault vault = player.PayVault; vault.Credit(100, "New player bonus", delegate(){ int newcoins = vault.Coins; //Show new amount to user. }); vault.Debit(10, "Race starting fee", delegate() { //Let player start race } Buying items with Coins is really easy. This requires that you have created an item in the PayVaultItems table in BigDB with the key "speedboost", and a property "PriceCoins" containing the price. PayVault vault = player.PayVault; vault.Buy(true, new BuyItemInfo[]{ new BuyItemInfo("speedboost") }, delegate() { int boosts = vault.Count("speedboost"); //Show new number of boosts to user. }); And here's how to consume an item: PayVault vault = player.PayVault; vault.Refresh(); VaultItem boost = vault.First("speedboost"); if (boost != null) { vault.Consume(new VaultItem[]{boost}, delegate() { //Boost the player's car }); } When it's time for a user to add more Coins, you can do it like this: PayVault vault = player.PayVault; vault.GetBuyCoinsInfo("socialgold", new Dictionary<string, string>(){{"offerid", "..."}}, delegate(Dictionary<string, string> result) { string url = result["socialgoldurl"]; //Show URL to player... }); And this is how to let the user buy an item directly. This requires that you have created an item in the PayVaultItems table in BigDB with the key "supercar", and a property "PriceUSD" containing the price. PayVault vault = player.PayVault; vault.GetBuyDirectInfo("paypal", new Dictionary<string, string>(){ {"currency", "USD"}, {"item_name", "Red Supercar"} }, new BuyItemInfo[]{ new BuyItemInfo("supercar").Set("Color", "Red") }, delegate(Dictionary<string, string> result) { string url = result["paypalurl"]; //Show URL to player... }); Finally, there are methods for retrieving the payment history of a user: PayVault vault = player.PayVault; vault.ReadHistory(0, 10, delegate(PayVaultHistoryEntry[] history) { if (history.Length > 0) { string lastprice = history[0].ProviderPrice; } }); This property contains the current coin balance of this Vault. This property can only be read on an up-to-date vault. This property contains the list of items in this Vault. This property can only be read on an up-to-date vault. This method checks if the Vault contains at least one item of the given itemKey. This method can only be called on an up-to-date vault. The itemKey to check for True if the user has at least one item of the given type (itemKey) Returns the first item of the given itemKey from this Vault. This method can only be called on an up-to-date vault. The itemKey of the item to get A VaultItem if one was found, or null if not Returns the number of items of a given itemKey is in this Vault. This method can only be called on an up-to-date vault. The itemKey of the items to count The number of items of the given type that the user has in the vault Refreshes this Vault, making sure the Items and Coins are up-to-date. Callback that will be called when the refresh is completed Refreshes this Vault, making sure the Items and Coins are up-to-date. Callback that will be called when the refresh is completed Callback that will be called instead of successCallback if an error occurs during the refresh. Loads a page of entries from this Vaults history, in reverse chronological order, i.e. newest first. The page of entries to load. The first page has number 0. The number of entries per page. Callback that will be called with the loaded PayVault history entries, or an empty array if none were found on the given page. Loads a page of entries from this Vaults history, in reverse chronological order, i.e. newest first. The page of entries to load. The first page has number 0. The number of entries per page. Callback that will be called with the loaded PayVault history entries, or an empty array if none were found on the given page. Callback that will be called instead of successCallback if an error occurs during the loading of history entries. Give coins to this Vault. The amount of coins to give. Your reason for giving the coins to this user. This will show up in the vault history, and in the PayVault admin panel for this user. Callback that will be called if the credit is succesful. Give coins to this Vault. The amount of coins to give. Your reason for giving the coins to this user. This will show up in the vault history, and in the PayVault admin panel for this user. Callback that will be called if the credit is succesful. Callback that will be called instead of successCallback if an error occurs. Take coins from this Vault The amount of coins to take. Your reason for taking the coins from this user. This will show up in the vault history, and in the PayVault admin panel for this user. Callback that will be called if the debit is succesful. Take coins from this Vault The amount of coins to take. Your reason for taking the coins from this user. This will show up in the vault history, and in the PayVault admin panel for this user. Callback that will be called if the debit is succesful. Callback that will be called instead of successCallback if an error occurs. Consume items in this Vault. This will cause them to be removed, but this action will not show up in the vault history. The VaultItems to use from the users vault - this should be instances from the Items array property. Callback that will be called if the use is succesful. Consume items in this Vault. This will cause them to be removed, but this action will not show up in the vault history. The VaultItems to use from the users vault - this should be instances from the Items array property. Callback that will be called if the use is succesful. Callback that will be called instead of successCallback if an error occurs. Buy items with Coins. If true, the items will be stored in the Vault. If false, the items will be consumed immediately after purchase. A list of items to buy, together with any additional payload. Callback that will be called if the buy is succesful. Buy items with Coins. If true, the items will be stored in the Vault. If false, the items will be consumed immediately after purchase. A list of items to buy, together with any additional payload. Callback that will be called if the buy is succesful. Callback that will be called instead of successCallback if an error occurs. Give the user items without taking any of his coins from the vault. Each BuyItemInfo instance contains the key of the item to give in the PayVaultItems BigDB table and any additional payload. Callback that will be called if the give is succesfull. Give the user items without taking any of his coins from the vault. Each BuyItemInfo instance contains the key of the item to give in the PayVaultItems BigDB table and any additional payload. Callback that will be called if the give is succesfull. Callback that will be called instead of successCallback if an error occurs. Gets information about how to make a coin purchase with the specified PayVault provider. The name of the PayVault provider to use for the coin purchase. Any additional information that will be given to the PayVault provider to configure this purchase. Callback that will be called with information about how to proceed with the purchase. Gets information about how to make a coin purchase with the specified PayVault provider. The name of the PayVault provider to use for the coin purchase. Any additional information that will be given to the PayVault provider to configure this purchase. Callback that will be called with information about how to proceed with the purchase. Callback that will be called instead of successCallback if an error occurs. Gets information about how to make a direct item purchase with the specified PayVault provider. The name of the PayVault provider to use for the coin purchase. Any additional information that will be given to the PayVault provider to configure this purchase. Each BuyItemInfo instance contains the key of the item to buy and any additional payload. Callback that will be called with information about how to proceed with the purchase. Gets information about how to make a direct item purchase with the specified PayVault provider. The name of the PayVault provider to use for the coin purchase. Any additional information that will be given to the PayVault provider to configure this purchase. Each BuyItemInfo instance contains the key of the item to buy and any additional payload. Callback that will be called with information about how to proceed with the purchase. Callback that will be called instead of successCallback if an error occurs. Use information from a provider to finalize a purchase with the specified PayVault provider. The name of the PayVault provider to use. The information needed to finalize this purchase. Callback that will be called with PayVault provider-specific information about the purchase. Use information from a provider to finalize a purchase with the specified PayVault provider. The name of the PayVault provider to use. The information needed to finalize this purchase. Callback that will be called with PayVault provider-specific information about the purchase. Callback that will be called instead of successCallback if an error occurs. An entry in a user's PayVault history The type of this entry, for example 'buy','credit','debit'... The coin amount of this entry. When this entry was created. The item keys related to this entry (entries with type 'buy'). The developer supplied reason for entries of type 'credit' and 'debit'. The transaction id from the PayVault provider corresponding to this entry. The price in real currency of this entry formatted as a human readable currency string, e.g. $10.00 USD Represents information about the purchase of a PayVault item. The minimum information necessary to create an instance of this class is an itemKey representing the PayVaultItem that should be purchased. It is also possible to add a custom payload, and this data will always be present when reading the item from the user's Vault. For example: Imagine that we have a racing game and users should be able to buy different cars of different colors, but that color doesn't affect the price of the car. Instead of creating one PayVaultItem for each combination of type and color, we need only create one item for each type and give them a different price, and color can then be added in the payload when buying a car. Setting the payload works exactly like manipulating a DatabaseObject from BigDB. //Buy a red 'simplecar' with stripes. player.PayVault.Buy(true, new BuyItemInfo[]{ new BuyItemInfo("simplecar").Set("Color", "Red").Set("Stripes", true) }, null); Creates a new BuyItemInfo to describe an item to purchase. They key of the underlying item in the PayVaultItems table. Returns the number of properties on this object Get the given property as an object Get the names of all properties on this object Removes all properties on this object Removes the value of the given property from this object Returns true if the given property exists on this object If the given property exists, this method returns true and the value as object in the out parameter. If it does not, this method return false Get the given property as an object Get the given string property Get the given string property, falling back to the given default value if the string property does not exist Get the given int property Get the given int property, falling back to the given default value if the int property does not exist Get the given uint property Get the given uint property, falling back to the given default value if the uint property does not exist Get the given long property Get the given long property, falling back to the given default value if the long property does not exist Get the given bool property Get the given bool property, falling back to the given default value if the bool property does not exist Get the given float property Get the given float property, falling back to the given default value if the float property does not exist Get the given double property Get the given double property, falling back to the given default value if the double property does not exist Get the given byte array property Get the given byte array property, falling back to the given default value if the byte array property does not exist Get the given datetime property Get the given datetime property, falling back to the given default value if the datetime property does not exist Get the given object property Get the given array property Set the given property to the given string value Set the given property to the given int value Set the given property to the given uint value Set the given property to the given long value Set the given property to the given bool value Set the given property to the given float value Set the given property to the given double value Set the given property to the given byte array value Set the given property to the given datetime value Set the given property to the given object Set the given property to the given array Represents information about an item in a user's Vault. The methods and properties in a VaultItem are very simliar to those of a DatabaseObject, except that it's read-only, and that there are some extra properties regarding the purchase. //Get a 'simplecar' from the Vault VaultItem car = player.PayVault.First("simplecar"); if (car != null) { string color = car.GetString("Color"); bool stripes = car.GetBool("Stripes"); } The unique id of this particular vault item in the users vault The key of the underlying item in the PayVaultItems BigDB table The time when the vault item was originally purchased Returns the number of properties on this object Get the given property as an object Get the names of all properties on this object Returns true if the given property exists on this object If the given property exists, this method returns true and the value as object in the out parameter. If it does not, this method return false Get the given property as an object Get the given string property Get the given string property, falling back to the given default value if the string property does not exist Get the given int property Get the given int property, falling back to the given default value if the int property does not exist Get the given uint property Get the given uint property, falling back to the given default value if the uint property does not exist Get the given long property Get the given long property, falling back to the given default value if the long property does not exist Get the given bool property Get the given bool property, falling back to the given default value if the bool property does not exist Get the given float property Get the given float property, falling back to the given default value if the float property does not exist Get the given double property Get the given double property, falling back to the given default value if the double property does not exist Get the given byte array property Get the given byte array property, falling back to the given default value if the byte array property does not exist Get the given datetime property Get the given datetime property, falling back to the given default value if the datetime property does not exist Get the given object property Get the given array property PlayerInsight The numbers of players online in the entire game Assign custom PlayerInsight segments to the current user Custom segments for the user in PlayerInsight, each string should be in the form 'segmentGroup:value', like 'adcampaign:googleads'. Callback that will be called when the operation succeeds Assign custom PlayerInsight segments to the current user Custom segments for the user in PlayerInsight, each string should be in the form 'segmentGroup:value', like 'adcampaign:googleads'. Callback that will be called when the operation succeeds Callback that will be called instead of successCallback if an error occurs during the operation. Gets the segment value for the given segment group. For instance, if the player is tagged in the segment 'source:facebook' the method will return 'facebook' when called with 'source' as the argument. The segmentGroup to get the current segment value for. Refresh the players online counter and the current segments of the user. Callback that will be called when the operation succeeds Refresh the players online counter and the current segments of the user. Callback that will be called when the operation succeeds Callback that will be called instead of successCallback if an error occurs during the operation. Tell PlayerInsight who invited the current user in this session. Used for viral analysis. The connectUserId of the user who invited this user. An identifier for the channel the invitation was received over, like 'email' or 'fb_invite'. Callback that will be called when the operation was completed successfully Tell PlayerInsight who invited the current user in this session. Used for viral analysis. The connectUserId of the user who invited this user. An identifier for the channel the invitation was received over, like 'email' or 'fb_invite'. Callback that will be called when the operation was completed successfully Callback that will be called instead of successCallback if an error occurs during the operation. Track the given event for the current user in PlayerInsight The name of the event to track. The amount to add to the counter value. Callback that will be called when the operation was completed successfully Track the given event for the current user in PlayerInsight The name of the event to track. The amount to add to the counter value. Callback that will be called when the operation was completed successfully Callback that will be called instead of successCallback if an error occurs during the operation. Track a completed payment in PlayerInsight from an external non-PayVault payment method. The currency the payment was made in. The amount of the payment in the given currency. Callback that will be called when the operation was completed successfully Track a completed payment in PlayerInsight from an external non-PayVault payment method. The currency the payment was made in. The amount of the payment in the given currency. Callback that will be called when the operation was completed successfully Callback that will be called instead of successCallback if an error occurs during the operation. An easy way to communicate with servers and services outside Player.IO via http requests Only paid Player.IO accounts can call these methods on the live servers, due to security concerns. They are always avaliable on the local development server however. You can fully develop your game locally using these methods without restrictions, and only upgrade to a paid account when you need to deploy your game to the live servers Below is an example of using the Get() method to download the contents of a web page in the GameStarted() method of a multiplayer room. public override void GameStarted() { var url = "http://www.mywebpage.com"; PlayerIO.Web.Get(url, delegate(HttpResponse response) { Console.WriteLine(response.Text); }); } Perform a HTTP Get request. The url to request, including querystring arguments (if any) Callback with a stream of the returned page Perform a HTTP Get request. The url to request, including querystring arguments (if any) Callback with a stream of the returned page Callback that will be called instead of successCallback if an error occurs during the request. Perform a HTTP Post request. The url to request, including querystring arguments (if any) The values to post to the given url Callback with a stream of the returned page Perform a HTTP Post request. The url to request, including querystring arguments (if any) The values to post to the given url Callback with a stream of the returned page Callback that will be called instead of successCallback if an error occurs during the request. The response from a HTTP Get or Post request Here's an example on how to grab the entire response and print it to the console: public override void GameStarted() { var url = "http://www.mywebpage.com"; PlayerIO.Web.Get(url, delegate(HttpResponse response) { Console.WriteLine(response.Text); }); } The status code returned from the remote web server A stream with the body of the http response The response stream read as an UTF8 string The method requested is not supported A general error occurred An unexpected error occurred inside the Player.IO webservice. Please try again. Access is denied The message is malformatted A value is missing A game is required to do this action An error occurred while contacting an external service The given argument value is outside the range of allowed values. The game has been disabled, most likely because of missing payment. The game requested is not known by the server The connection requested is not known by the server The auth given is invalid or malformatted There is no server in any of the selected server clusters for the game that are eligible to start a new room in (they're all at full capacity or there are no servers in any of the clusters). Either change the selected clusters for your game in the admin panel, try again later or start some more servers for one of your clusters. The room data for the room was over the allowed size limit You are unable to create room because there is already a room with the specified id The game you're connected to does not have a room type with the specified name There is no room running with that id You can't join the room when the RoomID is null or the empty string The room already has the maxmium amount of users in it. The key you specified is not set as searchable. You can change the searchable keys in the admin panel for the server type The QuickConnect method (simple, facebook, kongregate...) is not enabled for the game. You can enable the various methods in the admin panel for the game The user is unknown The password supplied is incorrect The supplied data is incorrect The key given for the BigDB object is not a valid BigDB key. Keys must be between 1 and 50 characters. Only letters, numbers, hyphens, underbars, and spaces are allowed. The object exceeds the maximum allowed size for BigDB objects. Could not locate the database object. The specified table does not exist. The specified index does not exist. The value given for the index, does not match the expected type. The operation was aborted because the user attempting the operation was not the original creator of the object accessed. The key is in use by another database object BigDB object could not be saved using optimistic locks as it's out of date. Cannot create circular references inside database objects The server could not complete the heartbeat The game code is invalid Cannot access coins or items before vault has been loaded. Please refresh the vault first. There is no PayVault provider with the specified id The specified PayVault provider does not support direct purchase The specified PayVault provider does not support buying coins The user does not have enough coins in the PayVault to complete the purchase or debit. The item does not exist in the vault. The chosen provider rejected one or more of the purchase arguments The chosen provider is not configured correctly in the admin panel Unable to locate the custom PartnerPay action with the given key The given type was invalid The index was out of bounds from the range of acceptable values The given identifier does not match the expected format The given argument did not have the expected value This client has been logged out The given segment was invalid. Cannot access requests before Refresh() has been called. Cannot access achievements before Refresh() has been called. Cannot find the achievement with the specified id. Cannot access notification endpoints before Refresh() has been called. The given notifications endpoint is invalid There is an issue with the network Cannot access OneScore before Refresh() has been called. The Publishing Network features are only avaliable when authenticated to PlayerIO using Publishing Network authentication. Authentication methods are managed in the connections setting of your game in the admin panel on PlayerIO. Cannot access profile, friends, ignored before Publishing Network has been loaded. Please refresh Publishing Network first. The dialog was closed by the user Check cookie required. The Player.IO ErrorLog service Here are some simple examples: PlayerIO.ErrorLog.WriteError("Error in my method"); try { //Some code that can throw an exception... } catch (Exception e) { PlayerIO.ErrorLog.WriteError("Exception in my method", e); } Write an entry to the game's error log. In development the errors are just written to the console, in production they're written to a database and browseable from the admin panel A short string describing the error without details. Example 'Unhandled exception' Write an entry to the game's error log. In development the error are just written to the console, in production they're written to a database and browseable from the admin panel A short string describing the error without details. Example 'Unhandled exception' The exception that caused the error Write an entry to the games error log. In development the error are just written to the console, in production they're written to a database and browseable from the admin panel A short string describing the error without details. Example 'Object not set to instance of an object' Describe the error in more detail if you have it. Example 'couldn't find the user 'bob' in the current game' The stacktrace (if available) of the error Any extra data you'd like to associate with the error log entry How many players are currently connected to this game room. This method is called when a game is closed. This method is called when a game is created. Called by the hosting server (in the production game server cluster) when it enters the NoJoin state. The game should take action accordingly. In order to support updating the system without abruptly ending games, rolling restarts are used which moves servers through 3 states: Live:Games can be created/joined and everything is perfect. NoCreate:No new instances can be created on the server (they'll just be created on any of the many other servers in the player.io cluster). NoJoin:Nobody can join the instances running on this server. Servers will start in live. When the system requires an update, the server will enter NoCreate and stay there for many hours (12-24). By then, most of the instances will have closed by natural causes (players leaving the games) and very few games will be left on the server. The server then enteres NoJoin where nobody can join the last few remaning instances. The NoJoin state lasts for about 6 hours, which gives the last few remaining games time to finish. The server will then shutdown where it's highly unlikely that any games remain. Since potentially games might still be running at the end of NoJoin (although it's highly unlikely), the ServerEnteredNoJoin method is called whenever the server changes state into NoJoin. This gives games the flexibility to handle the rolling restarts in a manner suited to their game. Only persistent games (MMO's) will need to use this method, and the most likely usecase is that they send out a "zone under maintenence, please reconnect" message to their client code, which simply rejoins the zone which will be created on another server. Generate an image that can be displayed in the development server Represents a message sent between client and server. A message consists of a string type, and a payload of zero or more typed parameters. For example here we create a simple message that the server broadcasts to connected players indicating that a round is starting: // message of type start with no payload Message m = Message.Create("start"); // send the message to all connected players Broadcast(m); Usually, it's much easier to simply use the convenience methods: public override void UserJoined(BasePlayer player) { // send the player a message of type "mapinfo" with two pieces // of data payload: the mapnam (string) and number of players (int) player.Send("mapinfo", "fields-of-glory", PlayerCount ); // broadcast to all connected players a message with type "userjoined" // and a single payload of just the player id (uint) Broadcast("userjoined", player.Id); } You can also build up messages as you go, if you don't know the exact payload untill runtime. In this example we send out the ConnectIds of all connected players to every new player that joins the room. public override void UserJoined(BasePlayer player) { // create a new message of type join Message joinMessage = Message.Create("join"); // add all the currently connected userids to the message foreach(var p in Players) { joinMessage.Add(p.ConnectUserId); } // send the message to the player who joined player.Send(joinMessage); } Create a new Message The type of message to create. A variable list of the data to add to the message. The type of the current message The number of data entries in the message, excluding the type. Get the data stored in the mesage at the given index Gets the string at the given indexThe index to find the entry in Gets the byte[] at the given indexThe index to find the entry in Gets the bool at the given indexThe index to find the entry in Gets the double at the given indexThe index to find the entry in Gets the float at the given indexThe index to find the entry in Gets the int at the given indexThe index to find the entry in Gets the int at the given indexThe index to find the entry in Gets the uint at the given indexThe index to find the entry in Gets the uint at the given indexThe index to find the entry in Gets the long at the given indexThe index to find the entry in Gets the ulong at the given indexThe index to find the entry in Gets the ulong at the given indexThe index to find the entry in Add a string to the message payload the value to add Add a int to the message payload the value to add Add a uint to the message payload the value to add Add a long to the message payload the value to add Add a ulong to the message payload the value to add Add a byte[] to the message payload the value to add Add a float to the message payload the value to add Add a double to the message payload the value to add Add a bool to the message payload the value to add Add multiple pieces of data to the message in one go. Adding a string, a number and two boolean values to the message. somemessage.Add("a string", 1234, true, false) The data to add to the message DEPRECATED DEPRECATED DEPRECATED DEPRECATED DEPRECATED DEPRECATED DEPRECATED DEPRECATED DEPRECATED DEPRECATED DEPRECATED DEPRECATED DEPRECATED DEPRECATED DEPRECATED DEPRECATED The country code of the user The country code of the user The country code of the user The country code of the user Property used to access the Http Request service. Property used to access the BigDB service. Property used to access the ErrorLog service. Property used to access the GameFS service. Property used to access the OneScore service Gets a PayVault object to access the PayVault of a target user. All functions call be called on this PlayerVault object except GetBuyCoinsInfo, GetBuyDirectInfo, and UseBuyInfo This example credits user1 10 coins and debits user2 10 coins { public override void GameStarted() { var user1PayVault = PlayerIO.GetUserPayVault("user1"); user1PayVault.Credit(10, "you earned some coins", null); var user2PayVault = PlayerIO.GetUserPayVault("user2"); user1PayVault.Debit(10, "you lost some coins", null); } } ]]> User id of the desired PayVault object Return a PayVault object for user Use the [RoomType] attribute to assign a room type to a Game class. [RoomType("MyRoomType")] public class MyGame : Game<MyPlayer> { ... } Assign this attribute to any method on your Game class, and the development server will feature buttons to trigger your method. This is great during development because it allows you to trigger events directly on the server without having to trigger them from your client If your method takes two int arguments (int x, int y), then your debug action will show up on clicks to the debug visualization. This code will cause a stop button to appear in the debug server when running the game. [DebugAction("Stop", DebugAction.Icon.Stop)] public void Stop() { Console.WriteLine("Stopping..."); } This is how you add a debug action that is accessible via the right-click context menu on the debug visualization in the development server. [DebugAction("Add Obstacle", DebugAction.Icon.Add)] public void PositionRock(int x, int y) { // set a rock on position (x,y) } For the really nitpicky developers, it's possible to embed an icon into a game and have it used instead of the builtin icons. In this case, a 16x16 png called add.png is embedded in the game dll: [DebugAction("Add Obstacle", "add.png")] public void PositionRock(int x, int y) { // set a rock on position (x,y) } A simple class to access resources embedded into the game assembly (.dll file). This class is useful along with the Game.GenerateDebugImage() method, because it allows you to grab embedded images and use them when rendering the debug image. To embed a file into the game assembly, add it to the project, right-click it in the solution explorer and choose Properties. In the properties pane, change the Build Action to Embedded Resource. The next time you build your solution that file will be copied into the assembly, and accessible through this class. Using the debug visualization system to generate a new debug image every second, and draw an image embedded as an embedded resource from the .dll file onto the debug image. public class MyGame : Game<BasePlayer> { public override void GameStarted() { // Update the debug view once a second. AddTimer(delegate { RefreshDebugView(); }, 1000); } public override Image GenerateDebugImage() { var img = new Bitmap(400, 400); using(var g = Graphics.FromImage(debugImage)) { // fill the background with blue g.FillRectangle(Brushes.Blue, 0, 0, img.Width, img.Height); // draw the embedded image "plane.png" at the offset (30,30) var embeddedImage = EmbeddedResource.GetImage("plane.png"); g.DrawImage(embeddedImage, 30, 30); } return img; } } Get the bytes[] of an embedded resource. The suffix of the embedded filename to search for. The bytes found, or null. Get an embedded resource as an image. The suffix of the embedded filename to search for. The image found, or null. A timer created by the Game.AddTimer(...) or Game.ScheduleCallback(...) methods Stops the timer. The timer cannot be restarted. The base class you inherit from for your Player class. For internal usage Every time a client connects, an Id is assigned that uniquely identifies them in the room as long as they remain connected. The UserId that was originally used when the client called PlayerIO.Connect(...) The ip address the player is connected from The data supplied by the client when the room was joined. That is, when the JoinRoom(...) or CreateJoinRoom(...) methods were called. The PlayerObject of the connected player in the "PlayerObjects" BigDB table.

This object is loaded via the GetPlayerObject() method or automatically when a player joins the game if the Game.PreloadPlayerObjects property is set to true.

The PayVault vault of the connected player The PartnerPay object of the connected player The PlayerInsight object of the connected player The Notifications object of the connected player The GameRequests object of the connected player The Achievements object of the connected player DEPRECATED The PlayerIO Publishing Network object of the connected player Gets the PlayerObject (from the BigDB PlayerObjects table) for the connected player. The object is loaded from BigDB on first load, then reused for subsequent GetPlayerObject requests, which means that subsequent calls to GetPlayerObjects will call the callback instantly. A callback that will be called with the loaded PlayerObject Reloads the PlayerObject from the BigDB PlayerObjects table A callback that will be called when the new playerobject is loaded. Send a message to the connected client The message to send Send a message to the connected client without first having to construct a Message object. The type of message to send The data to put in the message to send Disconnects the client from the room. Override this method to provide custom debug data for the playerlist in the development server. Each key-value pair is displayed in the playerlist as a column value, instead of the default one-column-per-property. This is how you'd override the method and provide two values for each player, that will show up in the development server. public override Dictionary<string, string> GetDebugValues() { var dict = new Dictionary<string, string>(); dict["sum"] = (2+2).ToString(); dict["description"] = "..."; return dict; } A dictionary of values to present in the debug server The room data for a given room. Besides the .Save() method, the class behaves exactly like a dictionary of string to string values. // reading a variable from room data var somevariable = RoomData["myvarname"]; // looping over all room data foreach(var kv in RoomData) { Console.WriteLine("RoomData[" + kv.Key + "] = " + kv.Value ); } // changing a variable and saving changes // so future ListRooms have the updated room data RoomData["myvariable"] = "new value"; RoomData.Save(); Save changes to room data so clients listing rooms will get the updated data The base class for all Player.IO Games. Inherit from this class to build your game. The Game class is the main serverside class of a Multiplayer Game. It contains methods that are called when messages are received, when players joins or leaves the game, and methods to interact with the players that are in the game. It's an abstract class, so you must create your game by inheriting from it. The Game class is also generic which means that it's parameterized and must be told what class is used to represent a player connected to a game. The player class must inherit from PlayerIO.GameLibrary.BasePlayer. Here is a simple bare-bones game and player implementation that simply broadcasts all received messages to all connected users. A bounce server if you will. public class MyPlayer : BasePlayer { // put properties here if you want them on your player } [RoomType("MyRoomType")] public class MyGame : Game<MyPlayer> { public override void GameStarted() { // a game has been created } public override void UserLeft(MyPlayer player) { // a user has left a game } public override void GotMessage(MyPlayer player, Message message) { // when getting a message, simply send it to all players connected // to the room. Broadcast(message); } } The type of the Players in your game. This must be a class that inherits from BasePlayer. Should new Player objects have their .PlayerObject loaded before they join the game?. Should new Player objects have their .PayVault objects loaded before they join the game?. How many players are currently connected to this game room. The data for the room. Room data is given when the room is created, returned when rooms are listed, and can be changed by the serverside game code. // reading a variable from room data var somevariable = RoomData["myvarname"]; // looping over all room data foreach(var kv in RoomData) { Console.WriteLine("RoomData[" + kv.Key + "] = " + kv.Value ); } // changing a variable and saving changes // so future ListRooms have the updated room data RoomData["myvariable"] = "new value"; RoomData.Save(); True if the game is currently running in the development server, False if the game is running in production. The id of the current room. This is the same id that would be used when calling JoinRoom(...) from a client. If the room is visible when listing rooms. Can be changed by your game code on the server. This property is useful when you want to create a room, spend some amount of time setting it up, and when that is done mark it as visible for others who list rooms. An enumerable list of all the players connected. Use foreach to loop over all the players. Calls the given delegate on each player in the room. The action to perform with each player. Register a message handler for the specific message type. You can use this to easily hookup delegates that are fired when messages of the given type are sent from the client. example: AddMessageHandler("update", delegate(Player player, Message message){ // this code will run when an "update" message is received }) Causes the development server to display the image returned by GenerateDebugImage(); Broadcast a message to all connected players the message to broadcast Broadcast a message to all connected players the type of the message to broadcast the data of the message to broadcast Called by the hosting server (in the production game server cluster) when it enters the NoJoin state. The game should take action accordingly. In order to support updating the system without abruptly ending games, rolling restarts are used which moves servers through 3 states: Live:Games can be created/joined and everything is perfect. NoCreate:No new instances can be created on the server (they'll just be created on any of the many other servers in the player.io cluster). NoJoin:Nobody can join the instances running on this server. Servers will start in Live. When the system requires an update, the server will enter NoCreate and stay there for many hours (12-24). By then, most of the instances will have closed by natural causes (players leaving the games) and very few games will be left on the server. The server then enters NoJoin where nobody can join the last few remaning instances. The NoJoin state lasts for about 6 hours, which gives the last few remaining games time to finish. The server will then shutdown where it's highly unlikely that any games remain. Since potentially games might still be running at the end of NoJoin (although it's highly unlikely), the ServerEnteredNoJoin method is called whenever the server changes state into NoJoin. This gives games the flexibility to handle the rolling restarts in a manner suited to their game. Only persistent games (MMO's) will need to use this method, and the most likely usecase is that they send out a "zone under maintenence, please reconnect" message to their client code, which simply rejoins the zone which will then be created on another server. Access to the Player.IO webservices Creates a new timer for calling a specified method at some interval. The method to be used for callbacks. Example usage: delegate(){ Console.WriteLine("called"); } The interval in milliseconds between callbacks A new Timer object Schedules a one-time callback in the future The method to be used for callbacks. Example usage: delegate(){ Console.WriteLine("called"); } The offset time in milliseconds for the timeout. Example: 1 second in the future is 1000 A new Timer object Called whenever a player attempts to join: If you override this method, simply return true to allow the join, and false to disallow the join. If you don't override it, it will allow everyone by default. Note that the user has not fully joined the game when this method is called, so Broadcast messages won't reach the user. Called whenever a client has joined the room. Called whenever a client leaves the room. The room is closed when the last person leaves the room. Called when data is received from the player. Use server cache to store information in a game server. This information will be available in all rooms hosted in the game server where you stored it but will not be available in all your rooms since multiple game servers are used to host all your rooms. Server cache is ideal to cache BigDb DatabaseObject or any other data that is expensive to gather.