コード例 #1
0
    //sync all objects with 'needsUpdate' flag to database
    //developer calls at own discretion
    public IEnumerator Sync(PrizmRecord <TMongoDocument> itemToSync)
    {
        Debug.Log("PrizmRecordGroup Sync() " + this.collectionKey);

        if (itemToSync.needsUpdate)
        {
            //forms a dictionary to pass into meteor's 'updateGameObject' from the record's databaseEntry parameters
            //simplify this for the developer in the future (maybe use an enum?)

            var methodCall = Meteor.Method <ChannelResponse> .Call("updateGameObject", itemToSync.mongoDocument._id, itemToSync.mongoDocument.toDictionary(), collectionKey);

            yield return((Coroutine)methodCall);

            if (methodCall.Response.success)
            {
                //Debug.LogError (associates[i].dbEntry._id + " should = " + methodCall.Response.message);
                itemToSync.dbUpdated();                         //tells the record that it was updated and it can rest now
            }
            else
            {
                //Debug.LogError ("Uh oh! database sync failed on record: " + itemToSync.name + ", with _id: " + itemToSync.mongoDocument._id);
            }

            yield return(null);
        }
        else
        {
            //Debug.LogError(itemToSync.name + "did not need to be updated, but Sync() was called on it");
        }
        Debug.Log("Finished with Sync()");
        yield return(null);
    }
コード例 #2
0
    //sync all objects with 'needsUpdate' flag to database
    //developer calls at own discretion
    public IEnumerator Sync(PrizmRecord itemToSync)
    {
        Debug.LogError("now syncing: " + itemToSync.ToString());

        if (itemToSync.needsUpdate)
        {
            //forms a dictionary to pass into meteor's 'updateGameObject' from the record's databaseEntry parameters
            //simplify this for the developer in the future (maybe use an enum?)
            Dictionary <string, string> dict = new Dictionary <string, string> ()
            {
                { "playersID", itemToSync.dbEntry.playersID },
                { "playersName", itemToSync.dbEntry.playersName },
                { "totalScore", itemToSync.dbEntry.totalScore.ToString() },
                { "timePlayed", itemToSync.dbEntry.timePlayed.ToString() }
            };


            var methodCall = Meteor.Method <ChannelResponse> .Call("updateGameObject", itemToSync.dbEntry._id, dict);

            yield return((Coroutine)methodCall);

            if (methodCall.Response.success)
            {
                //Debug.LogError (associates[i].dbEntry._id + " should = " + methodCall.Response.message);
                itemToSync.dbUpdated();                         //tells the record that it was updated and it can rest now
            }
            else
            {
                Debug.LogError("Uh oh! database sync failed on record: " + itemToSync.ToString() + ", with _id: " + itemToSync.dbEntry._id);
            }
        }
        else
        {
            Debug.LogError(itemToSync.ToString() + "did not need to be updated, but Sync() was called on it");
        }
        Debug.Log("Finished with Sync()");
        yield return(null);
    }
コード例 #3
0
    //sync all objects with 'needsUpdate' flag to database
    //developer calls at own discretion
    public IEnumerator Sync(PrizmRecord itemToSync)
    {
        Debug.LogError ("now syncing: " + itemToSync.name);

        if (itemToSync.needsUpdate) {
            //forms a dictionary to pass into meteor's 'updateGameObject' from the record's databaseEntry parameters
            //simplify this for the developer in the future (maybe use an enum?)
            Dictionary<string, string> dict = new Dictionary<string, string> () {
                {"location", itemToSync.dbEntry.location}
            };

            var methodCall = Meteor.Method<ChannelResponse>.Call ("updateGameObject", itemToSync.dbEntry._id, dict);
            yield return (Coroutine)methodCall;
            if (methodCall.Response.success) {
                //Debug.LogError (associates[i].dbEntry._id + " should = " + methodCall.Response.message);
                itemToSync.dbUpdated();		//tells the record that it was updated and it can rest now
            } else {
                Debug.LogError ("Uh oh! database sync failed on record: " + itemToSync.name + ", with _id: " + itemToSync.dbEntry._id);
            }

        } else {
            Debug.LogError(itemToSync.name + "did not need to be updated, but Sync() was called on it");
        }
        Debug.LogError ("Finished with Sync()");
        yield return null;
    }