在Google Drive Realtime API中创建自定义对象时出错

时间:2014-02-13 19:36:32

标签: javascript object google-drive-realtime-api

好的,我正在尝试按照Google开发者指南https://developers.google.com/drive/realtime/build-model#registering_and_creating_custom_objects在Google Realtime API中创建协作自定义对象。但是,它现在运行正常,但是,当我尝试在模型中创建一个对象时(在initializeModel函数中取出注释中的两行),我得到错误“log:Net state从BUSY更改为CLIENT_ERROR” 。 JavaScript中没有错误。我不知道我哪里出错,任何帮助都表示赞赏。谢谢,

        Project = function() {};
    registerTypes = function() {
        var custom = gapi.drive.realtime.custom;
        custom.registerType(Project, 'Project');                            
        Project.prototype.title = gapi.drive.realtime.custom.collaborativeField('title');
        Project.prototype.date = gapi.drive.realtime.custom.collaborativeField('date');
        Project.prototype.content = gapi.drive.realtime.custom.collaborativeField('content');
}
/**
 * Set up the model - when creating a new file or loading an existing one.
 */

// the model for the messages in the chat
var messages = undefined;
// the name of the authenticated user - once authentication has succeeded
var username = "unkown";
var realtimeLoader = undefined;

/**
 * Set up the model - when creating a new file or loading an existing one.*/
var initializeModel = function(model) {
    var messages = model.createList();
    var dealines2 = model.createList();
    /*var project1 = model.create("Project");*/
    model.getRoot().set('messages', messages);
    /*model.getRoot().set('project1', project1);*/
    model.getRoot().set('dealines2', dealines2);
    console.log(model.getRoot());
}

1 个答案:

答案 0 :(得分:0)

你有没有打过registerTypes?在加载文档之前需要注册类型。