Exemple #1
0
    private IEnumerator downloadJson(string storyName, string jsonFile,
                                     Action <Dictionary <string, StoryJson> > onDownloadComplete)
    {
        string url = Constants.JSON_BASE_URL + storyName + '/' + jsonFile + ".json";
        //Logger.Log("started download of json " + url);
        WWW www = new WWW(url);

        yield return(www);

        StoryJson json = new StoryJson(jsonFile, www.text);

        this.jsonMidDownload[jsonFile] = json;
        // Logger.Log("completed download of json " + url);
        this.checkJsonDownloadComplete(storyName, onDownloadComplete);
    }
Exemple #2
0
    // Test downloading a json file from S3.
    // TODO: think about using S3 API for all of the downloading, right now it's straight WWW.
    //
    // Note that this happens asynchronously (caller doesn't block) even though Unity says it
    // happens synchronously, and also that the errors in Visual Studio are actually ok in Unity.
    public void S3GetStoryJson(string jsonFileName, Action <StoryJson> callback = null)
    {
        string storyName = Util.FileNameToStoryName(jsonFileName);

        this.s3Client.GetObjectAsync(
            Constants.S3_JSON_BUCKET, storyName + "/" + jsonFileName + ".json",
            (responseObj) => {
            using (Stream responseStream = responseObj.Response.ResponseStream)
                using (StreamReader reader = new StreamReader(responseStream))
                {
                    string responseBody = reader.ReadToEnd();
                    Logger.Log(responseBody);
                    StoryJson json = new StoryJson(jsonFileName, responseBody);
                    callback?.Invoke(json);
                }
        });
    }