コード例 #1
0
    IEnumerator Login(string username, string password)
    {
        NetObj loginRequest = new NetObj();

        loginRequest.resourcePath = API_CLIENT.serverLocation + "api/login";
        loginRequest.payload      = "{\n\"username\":\"" + username + "\",\n\"password\":\"" + password + "\"\n}";

        loginScreen.SetActive(false);
        loginButton.SetActive(false);
        connectionSprite.SetActive(true);

        yield return(loginRequest.Post());

        connectionSprite.SetActive(false);

        if (loginRequest.responce.responseHeaders ["STATUS"] == API_CLIENT.okCode)
        {
            loggedIn = true;
            successScreen.SetActive(true);
            Debug.Log(loginRequest.responce.text);
        }
        else
        {
            Debug.Log(loginRequest.responce.text);
            loginScreen.SetActive(true);
            loginButton.SetActive(true);
        }
    }
コード例 #2
0
    // Use this for initialization
    IEnumerator Start()
    {
        // Test code -- To be moved out into a connection testing function/class.
        // Asks if server is online, via api/status which returns an ok 200 http responce.
        NetObj callServer = new NetObj();

        callServer.contentType  = "";
        callServer.resourcePath = serverLocation + "api/status";
        yield return(callServer.Post());

        if (callServer.responce.responseHeaders ["STATUS"] == okCode)
        {
            isServerAlive = true;
        }
    }