Game Development Reference
In-Depth Information
StartCoroutine(WaitForRequest(www));
}
IEnumerator WaitForRequest(WWW www)
{
yield return www;
//check for errors
if (www.error == null)
{
Debug.Log("Successful: " + www.text);
}
else
{
Debug.Log("Error: " + www.error);
}
}
This simply takes the byte array of the serialized saved data and posts it to your server.
Alternatively, you can post data to the server as a form (more common):
void WebPost2()
{
string url = "http://mybackendserver.com/Upload.php";
var playerSerializedState =
SerializerHelper.Serialise<PlayerSaveState>
(currentPlayer.GetPlayerSaveState());
var data = Convert.ToBase64String(playerSerializedState);
WWWForm saveForm = new WWWForm();
saveForm.AddField("saveData", data);
WWW www = new WWW(url, saveForm);
StartCoroutine(WaitForRequest(www));
}
This makes a traditional HTTP post with parameters in the body of the request.
Search WWH ::




Custom Search