Exemplo n.º 1
0
        IEnumerator RemoteSPCo(string eWords, Taker <GrammarBlock> listener)
        {
            inteceptHelper.OnBeginSession(listener);
            var  form       = new WWWForm();
            bool didCollect = false;

            form.AddBinaryData("ewords", System.Text.Encoding.UTF8.GetBytes(eWords));
            UnityWebRequest www = UnityWebRequest.Post(uri, form);

            yield return(www.SendWebRequest());

            if (www.isNetworkError || www.isHttpError)
            {
                Debug.Log("HTML_MonoBLProcessor: " + www.error);
            }
            else
            {
                Debug.Log(Encoding.UTF8.GetString(www.downloadHandler.data));
                var gblock = RequiredFuncs.FromJson <DeserializedGBlock>(www.downloadHandler.data);
                listener.Take(gblock);
                didCollect = true;
            }
            inteceptHelper.OnEndSession(listener);
            if (!didCollect)
            {
                listener.None();
            }
        }
Exemplo n.º 2
0
 void AssetReferer.ReferAsset(AssetUnitInfo assetUnitInfo, AssetReferenceListener listener)
 {
     if (assetUnitInfo.reference.StartsWith("unityab:"))
     {
         listener.OnBeginRefering();
         var json  = assetUnitInfo.reference.Substring(8);
         var abRef = RequiredFuncs.FromJson <AssetBundleRef>(json);
         NetworkUtil.ProcessWebRequest(
             UnityWebRequestAssetBundle.GetAssetBundle(abRef.uri, 0),
             (www) => {
             var bundle = DownloadHandlerAssetBundle.GetContent(www);
             if (string.IsNullOrEmpty(abRef.assetPath))
             {
                 //stub
             }
             else
             {
                 var bundleAsset = bundle.LoadAsset(abRef.assetPath);
                 if (bundleAsset != null)
                 {
                     listener.OnObjectObtained(bundleAsset, abRef.assetPath);
                 }
             }
             listener.OnFinish();
         }
             );
     }
 }
Exemplo n.º 3
0
 void AssetReferer.ReferAsset(AssetUnitInfo assetUnitInfo, AssetReferenceListener listener)
 {
     if (assetUnitInfo.reference.StartsWith("platform:"))
     {
         var json        = assetUnitInfo.reference.Substring(9);
         var pRef        = RequiredFuncs.FromJson <PlatformRef>(json);
         var auInfoClone = AssetUtils.CloneAssetRef(assetUnitInfo);
         auInfoClone.reference = pRef.defaultBuild;
         baseReferer.assetReferer.ReferAsset(auInfoClone, listener);
     }
 }
Exemplo n.º 4
0
        public void SendNCSRequest(SimpleProcessListener listener)
        {
            if (pendingNCSReq.units.Count == 0)
            {
                return;
            }
            var reqInJson = RequiredFuncs.ToJsonString(pendingNCSReq);

            pendingNCSReq = new NounCommonSenseRequest {
                units = new List <NounCommonSenseRequestUnit>()
            };
            var copiedTakers = pendingNCSTakers;

            pendingNCSTakers = new Dictionary <string, List <Taker <NounCommonSenseUnit> > >();
            var wwwForm = new WWWForm();

            wwwForm.AddField("ncsReqInJson", reqInJson);
            Debug.Log("CommonSenseReq: " + reqInJson);
            UnityWebRequest www = UnityWebRequest.Post(serverURL + "GetNounCommonSense", wwwForm);

            NetworkUtil.ProcessWebRequest(www, (givenWebReq) => {
                if (www.error != null)
                {
                    listener.OnFinish(false);
                    return;
                }
                var ncs = RequiredFuncs.FromJson <StoredNounCommonSense>(www.downloadHandler.text);
                Debug.Log(www.downloadHandler.text);
                foreach (var ncsUnit in ncs.units)
                {
                    foreach (var pair in copiedTakers)
                    {
                        if (pair.Key.Equals(ncsUnit.noun, StringComparison.CurrentCultureIgnoreCase))
                        {
                            foreach (var collector in pair.Value)
                            {
                                cachedNCS.Add(ncsUnit);
                                collector.Take(ncsUnit);
                            }
                        }
                        else
                        {
                            foreach (var collector in pair.Value)
                            {
                                collector.None();
                            }
                        }
                    }
                }
            });
        }