bmob-Mobile back-end cloud service platform

Source: Internet
Author: User

For individuals or small teams, it is not easy to develop a network-enabled game, and a server development language such as java/.net/php must be mastered.

Bmob Cloud Service facilitates the developer. Bmob can quickly add a secure and flexible back-office management system to the application software, so as to easily browse the various information saved by the terminal, so that developers can not focus on the backend of the server, only need to use the Bmob android/ios/cocos2d-x/unity and other SDK can be implemented.

Let's look at a simple example of how bmob is used.

1. Register an account on the Bmob website. (Bmob official website: http://www.bmob.cn/)

2. Download the CSharp SDK. There are three files in it: Unity,windows and WindowsPhone8, we need the bmob-unity.dll under Unity to put the file under the Libs folder in the project.

3. Create an app in the app panel to get the app's key (application ID). Under Data browsing, create the tables and fields that you want. (New score table, create score and playername two fields)

4. Hang the bmobunity script on the camera, and application ID sticks to it.

5. Create model models corresponding to the score table: Bmobgameobject:bmobtable, the Bmobtable interface must be implemented.

usingUnityengine;usingSystem.Collections;usingCn.bmob.io; Public classbmobgameobject:bmobtable{//score, PlayerName is the field name corresponding to the background data table     PublicBmobint Score {Get;Set; }  Public stringPlayerName {Get;Set; } //reading from a data table     Public Override voidreadfields (Bmobinput input) {Base. ReadFields (input);  This. score = Input.getint ("score");  This. PlayerName = Input.getstring ("PlayerName"); }    //Writing data Tables     Public Override voidWrite (Bmoboutput output,BOOLAll ) {        Base. Write (output, all); Output. Put ("score", This. Score); Output. Put ("PlayerName", This. PlayerName); }}

6. Testing

usingUnityengine;usingSystem.Collections;usingCn.bmob.api;usingCn.bmob.io;usingSystem.Collections.Generic; Public classBmobtest:monobehaviour {Privatebmobunity Bmob; Private stringTableName; //Use this for initialization    voidStart () {Bmob= This. Getcomponent<bmobunity>(); TableName="score"; }        //Update is called once per frame    voidUpdate () {#regionAdd a row of data Spaceif(Input.getkeydown (keycode.space)) {//Creating Data Objects            vardata =NewBmobgameobject (); //Setting the valueSystem.Random rnd =NewSystem.Random (); Data.score= rnd. Next (0, -); Data.playername="player"+ rnd. Next (1,Ten); ; //add a row of data, score to the new data table nameBmob. Create (TableName, data, (resp, exception) =            {                if(Exception! =NULL) {print ("the save failed with the reason for the failure:"+exception.                    Message); return; } Print ("saved successfully, @"+Resp.createdat); //Resp.objectid            }); }        #endregion        #regionGets A row of data Aif(Input.getkeydown (keycode.a)) {stringObjectId ="d95534876e"; Bmob. Get<BmobGameObject> (TableName, ObjectId, (resp, exception) =            {                if(Exception! =NULL) {print ("the query failed with the reason for the failure:"+exception.                    Message); return; } Bmobgameobject Game=resp; Print ("the objects obtained are:"+game.                ToString ()); Print ("gets the score for the object:"+game.score.ToString ());        }); }               #endregion        #regionModify a row of data Bif(Input.getkeydown (keycode.b)) {Bmobgameobject game=NewBmobgameobject (); Game.playername="pn_123"; stringObjectId ="d95534876e"; Bmob. Update (TableName, ObjectId, Game, (RESP, exception)=            {                if(Exception! =NULL) {print ("The modification failed with the reason for the failure:"+exception.                    Message); return; } Print ("modified successfully, @"+Resp.updatedat);        }); }        #endregion        #regionDelete a row of data Dif(Input.getkeydown (KEYCODE.D)) {stringObjectId ="d95534876e"; Bmob. Delete (TableName, ObjectId, (RESP, exception)=            {                if(Exception! =NULL) {print ("the deletion failed with the reason for the failure:"+exception.                    Message); return; } Print ("Delete succeeded, @"+resp.msg);        }); }        #endregion        #regionQuery all Data Qif(Input.getkeydown (KEYCODE.Q)) {//Create a bmobquery query objectBmobquery query =NewBmobquery (); //querying for records with PlayerName field values of Player1Query. Whereequalto ("PlayerName","Player1"); //by default, the system does not actually return all the data, but instead returns 10 data records by default, and you can set the number of records returned by the Setlimit method//query.     Limit ("20"); Query.            Skip (20); //conditional query query.where in SQL ... To JudgeBmob. Find<bmobgameobject> (tableName, Query, (resp, exception) =            {                if(Exception! =NULL) {print ("the query failed with the reason for the failure:"+exception.                    Message); return; }                //list<t> namespace System.collections.generic.ilist<t>//to process the returned resultslist<bmobgameobject> list =Resp.results; foreach(varGameinchlist) {Print ("the objects obtained are:"+game.                ToString ());         }            }); }        #endregion    }}

Bmob background data is as follows:

bmob-Mobile back-end cloud service platform

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.