1

我有一个使用 XAPI 将确定的信息发送到数据库并显示它的应用程序,当我在计算机上的 Unity 编辑器中运行该应用程序时,XAPI 通信工作正常,但是当我将 APK 放入我的手机时,它不会发送信息,当尝试几个语句时,应用程序会冻结。我在视频中实现了 XAPI:https ://www.youtube.com/watch?v=zX8Pq9STvoo并且计算机或移动设备都没有与 LRS 在同一个网络中。凭据是正确的,因为可以使用编辑器发送语句。发送函数如下:

void SendStatement_key(string verb_key , string actor_key, string definition_key)
{
    //Build out Actor details
    Agent actor = new Agent();
    actor.mbox = "mailto:"+ actor_key.Replace(" ", "")+"@learninglocker.net";
    actor.name = actor_key;

    //flag_4.change_bool_false();

    //Build out Verb details
    Verb verb = new Verb();
    verb.id = new Uri("http://www.example.com/" + verb_key);
    verb.display = new LanguageMap();
    verb.display.Add("en-US", verb_key);

    //Build out Activity details
    Activity activity = new Activity();
    activity.id = new Uri("http://www.example.com/" + definition_key.Replace(" ", "")).ToString();

    //Build out Activity Definition details
    ActivityDefinition activityDefinition = new ActivityDefinition();
    activityDefinition.description = new LanguageMap();
    activityDefinition.name = new LanguageMap();
    activityDefinition.name.Add("en-US", (definition_key));
    activity.definition = activityDefinition;

    Result result = new Result();
    Score score = new Score();

    score.raw = _value;
    result.score = score;

    //Build out full Statement details
    Statement statement = new Statement();
    statement.actor = actor;
    statement.verb = verb;
    statement.target = activity;
    statement.result = result;

    //Send the statement
    StatementLRSResponse lrsResponse = lrs.SaveStatement(statement);
    if (lrsResponse.success) //Success
    {
        Debug.Log("Save statement: " + lrsResponse.content.id);
    }
    else //Failure
    {
        Debug.Log("Statement Failed: " + lrsResponse.errMsg);
    }
}
4

0 回答 0