void doAuthentication(string username, string password)
 {
     // if there is no token stored, negotiate a new one
     HTTPRequest req = new HTTPRequest (new System.Uri (Properties.API + "/authenticate"), HTTPMethods.Post, onAuthenticationFinished);
     req.AddField ("username", username);
     req.AddField ("password", password);
     req.Send ();
 }
    private void OnClick()
    {
        HTTPRequest request = new HTTPRequest(new Uri(APIUrl.UrlLogin), HTTPMethods.Post, OnRequestFinished);
        request.AddField("username", username.text);
        request.AddField("password", password.text);
        request.Send();

        //SceneManager.LoadScene(1);
    }
 // create a new game
 public void createGame()
 {
     string challenger = PlayerPrefs.GetString("username");
     string challenged = (challenger == "berni") ? "gemmins" : "berni";
     Debug.Log (PlayerPrefs.GetString("token"));
     HTTPRequest request = new HTTPRequest (new System.Uri (Properties.API + "/game"), HTTPMethods.Post, (HTTPRequest req, HTTPResponse res) => {
         //TODO: jump to the new game
     });
     request.AddField ("challenger", challenger);
     request.AddField ("challenged", challenged);
     request.AddField ("token", PlayerPrefs.GetString("token"));
     request.Send ();
 }
 // get game info from API
 void getGame()
 {
     // get all the games
     HTTPRequest request = new HTTPRequest(new System.Uri(Properties.API + "/game/" + _gameId), (HTTPRequest req, HTTPResponse res) => {
         // deserialize json
         GameModel games = JsonMapper.ToObject<GameModel> (res.DataAsText);
         // build scene
         buildScene(games);
     });
     request.AddField ("token", PlayerPrefs.GetString ("token"));
     request.Send ();
 }
        protected override void SendImpl(string json)
        {
            var request = new HTTPRequest(Connection.BuildUri(RequestTypes.Send, this), HTTPMethods.Post, true, true, OnSendRequestFinished);

            request.FormUsage = Forms.HTTPFormUsage.UrlEncoded;
            request.AddField("data", json);

            Connection.PrepareRequest(request, RequestTypes.Send);

            // Set a lower priority then the default. This way requests that are sent out alonside with SignalR sent requests can be processed sooner.
            request.Priority = -1;

            request.Send();

            sendRequestQueue.Add(request);
        }
 private void OnClick()
 {
     // Debug.Log(characterList.GetIndex(characterSelected.centeredObject.transform).ToString());
     if (!confirmPassword.text.Equals(password.text))
     {
         return;
     }
     HTTPRequest request = new HTTPRequest(new Uri(APIUrl.UrlSignup), HTTPMethods.Post, OnRequestFinished);
     request.AddField("username", username.text);
     request.AddField("password", password.text);
     request.AddField("score", "0");
     request.AddField("email", username.text + "*****@*****.**");
     int n = characterList.GetIndex(characterSelected.centeredObject.transform);
     request.AddField("characterId", characteritemlist[n].id);
     request.Send();
 }