Hi I hope someone can help me. Since my provider doesn't offer websockets like node.js I can only poll my php scripts from the server to check if a value in my database has changed. Since I need the update only ever 5 oder 10 minutes it shouldn't be a big problem but I don't know how to implement the polling in Unity. I made a gameobject with my script: Code (csharp): public class Polling : MonoBehaviour { Thread WorkerThread; bool m_bEnd = false; void Start () { WorkerThread = new Thread(new ThreadStart(PollData)); WorkerThread.Start(); } void PollData() { while (m_bEnd == false) { StartCoroutine(GetDataFromServer()); Thread.Sleep(600000); // poll Server only after 10 min } } private IEnumerator GetDataFromServer() { string strUrl; WWW www; strUrl = "http://www.myserver.de/myscript.php"; www = new WWW(strUrl); //GET data is sent via the URL while (!www.isDone && string.IsNullOrEmpty(www.error)) { yield return null; } // Do something with the results // ... } void OnApplicationQuit() { m_bEnd = true; } } Well when I added some debug logs then I could see the thread is sleeping for 10 minutes and then he woke up like I expected it. But when I added the www request I can see that the request is never called. I guess the reason is that the thread goes to sleep after calling the coroutine but I don't know what other way I could implement a polling
have you taken a look at InvokeRepeating? all you need to pass is the method name and to floats for the timers