コード例 #1
0
 // Use this for initialization
 void AssetRequestPublisher.PublishAssetRequest(AssetRequest assetReq, SimpleProcessListener listener)
 {
     RequiredFuncs.ProcessHTTP(
         "https://api.taiga.io/api/v1/auth",
         (response) => {
         var auth           = RequiredFuncs.FromJson <TaigaIOUserInfo>(response);
         var headerWithAuth = new KeyValuePair <string, string>[] {
             new KeyValuePair <string, string>("Content-Type", "application/json"),
             new KeyValuePair <string, string>("Authorization", "Bearer " + auth.auth_token)
         };
         RequiredFuncs.ProcessHTTP(
             "https://api.taiga.io/api/v1/userstories?project=" + projectID,
             (storiesJson) => {
             var stories = RequiredFuncs.FromJsonToArray <TaigaIOUserStory>(storiesJson);
             foreach (var reqUnit in assetReq.units)
             {
                 if (reqUnit.attributes.Count == 0)
                 {
                     continue;
                 }
                 var storySubjForReq        = "Asset Wanted: " + reqUnit.attributes[0] + " " + reqUnit.assettype;
                 bool shouldPublishAssetReq = true;
                 foreach (var story in stories)
                 {
                     if (story.subject == storySubjForReq)
                     {
                         shouldPublishAssetReq = false;
                         break;
                     }
                 }
                 if (shouldPublishAssetReq)
                 {
                     RequiredFuncs.ProcessHTTP(
                         "https://api.taiga.io/api/v1/userstories",
                         (addStoryResponseText) => {
                         RequiredFuncs.Log(RequiredFuncs.ToJsonString(new TaigaIOUserStoryAdd {
                             subject = storySubjForReq, project = projectID
                         }));
                     },
                         headerWithAuth,
                         RequiredFuncs.ToJson(new TaigaIOUserStoryAdd {
                         subject = storySubjForReq, project = projectID
                     })
                         );
                 }
             }
             listener.OnFinish(true);
         },
             headerWithAuth
             );
     },
         new KeyValuePair <string, string>[] { new KeyValuePair <string, string>("Content-Type", "application/json") },
         RequiredFuncs.ToJson(new TaigaIOAuth {
         username = username, password = password, type = "normal"
     })
         );
 }
コード例 #2
0
ファイル: StdAssetSuppliers.cs プロジェクト: iwaag/AGDevUnity
        void AssetSupplier.SupplyAsset(AssetRequest assetRequest, AssetSupplyListener listener)
        {
            Debug.Log("Begin fetching assets.");
            inteceptHelper.OnBeginSession(listener);
            var assetRequestJson = JsonUtility.ToJson(assetRequest);

            Debug.Log("Forward requst to Web.... " + assetRequestJson);
            WWWForm wwwForm = new WWWForm();

            wwwForm.AddField("assetRequestInJson", assetRequestJson);
            UnityWebRequest www = UnityWebRequest.Post(serverURL, wwwForm);

            NetworkUtil.ProcessWebRequest(www, (givenWebReq) => {
                bool didSuccess = false;
                if (givenWebReq.isNetworkError || givenWebReq.isHttpError)
                {
                    Debug.Log(givenWebReq.error);
                }
                else
                {
                    Debug.Log(Encoding.UTF8.GetString(givenWebReq.downloadHandler.data));
                    var assetPick = RequiredFuncs.FromJson <AssetPick>(givenWebReq.downloadHandler.data);
                    if (assetPick != null)
                    {
                        if (assetPick.units.Count > 0)
                        {
                            didSuccess = true;
                            listener.supplyTaker.Take(assetPick);
                        }
                    }
                }
                if (!didSuccess)
                {
                    listener.supplyTaker.None();
                }
                inteceptHelper.OnEndSession(listener);
            }
                                          );
        }
コード例 #3
0
 void AssetModifyInterface.SetContent <ContentType>(AssetContentSettingParam <ContentType> setParam, AssetInResultListener <ContentType> listener)
 {
     if (string.IsNullOrEmpty(setParam.contentPath))
     {
         if ((typeof(MainContentBaseType) == typeof(ContentType)))
         {
             basicAssetIO.assetIn.SetContent(new BasicAssetInParam <ContentType> {
                 content     = setParam.content,
                 contentPath = "Main.json",
                 doOverwrite = setParam.doOverwrite
             }, listener);
         }
         else if (typeof(MainContentType) == typeof(ContentType))
         {
             basicAssetIO.assetIn.SetContent(new BasicAssetInParam <ContentType> {
                 content     = setParam.content,
                 contentPath = "Main.json",
                 doOverwrite = setParam.doOverwrite
             }, listener);
         }
         else if (typeof(byte[]) == typeof(ContentType))
         {
             basicAssetIO.assetIn.SetContent(new BasicAssetInParam <MainContentType> {
                 content     = RequiredFuncs.FromJson <MainContentType>(Encoding.UTF8.GetString((byte[])(object)setParam.content)),
                 contentPath = "Main.json",
                 doOverwrite = setParam.doOverwrite
             }, new StubAssetInResultListener <MainContentType>());
         }
     }
     else
     {
         basicAssetIO.assetIn.SetContent(new BasicAssetInParam <ContentType> {
             content     = setParam.content,
             contentPath = setParam.contentPath,
             doOverwrite = setParam.doOverwrite
         }, listener);
     }
 }