コード例 #1
0
ファイル: UniumMinion.cs プロジェクト: ivdstudios/unium
    ////////////////////////////////////////////////////////////////////////////////////////////////////

    IEnumerator OverlordRestful()
    {
        // get about

        var route = Unium.RoutesHTTP.Find("/about");

        if (route == null || route.Handler == null)
        {
            Debug.LogWarning("UniumMinion failed to find valid /about route");
            yield break;
        }

        var req = new RequestAdapterMemory("/about");

        route.Dispatch(req);

        if (req.IsError)
        {
            Debug.LogWarning("UniumMinion failed to get /about data");
            yield break;
        }

        // post data to end point
        bool isError = false;

#if UNITY_2017_3_OR_NEWER
        var www = UnityWebRequest.Post(URL, req.Data);
        yield return(www.SendWebRequest());

        isError = www.isNetworkError || www.isHttpError;
#else
        var www = new WWW(URL, Encoding.UTF8.GetBytes(req.Data));
        yield return(www);

        isError = www.error != null;
#endif

        if (isError)
        {
            Debug.LogWarning("UniumMinion failed to register with overlord: " + www.error);
        }
        else
        {
            Debug.Log("UniumMinion registered with overlord OK");
        }
    }
コード例 #2
0
ファイル: UniumMinion.cs プロジェクト: teaclipper/unium
    ////////////////////////////////////////////////////////////////////////////////////////////////////

    IEnumerator OverlordRestful()
    {
        // get about

        var route = Unium.RoutesHTTP.Find("/about");

        if (route == null || route.Handler == null)
        {
            Debug.LogWarning("UniumMinion failed to find valid /about route");
            yield break;
        }

        var req = new RequestAdapterMemory("/about");

        route.Dispatch(req);

        if (req.IsError)
        {
            Debug.LogWarning("UniumMinion failed to get /about data");
            yield break;
        }

        // post data to end point

        var www = new WWW(URL, Encoding.UTF8.GetBytes(req.Data));

        yield return(www);

        if (www.error != null)
        {
            Debug.LogWarning("UniumMinion failed to register with overlord: " + www.error);
        }
        else
        {
            Debug.Log("UniumMinion registered with overlord OK");
        }
    }