[SOLVED] Server poll technology / timer

Hi everyone!
I want my PlayCanvas app to communicate regularly with a server, uploading and downloading data. This should happen e.g. every 200 milliseconds (5 times per second). When data comes back from the server, I will update some global variables from these values.

Two questions about this:

  1. I thought I would do the communication via HTTP GET requests. Is this an OK approach or is there a better way to do server communication with PlayCanvas?
  2. How do I write a timer / scheduler that talks to the server e.g. every 200 ms?

Any pointers are appreciated. Thanks a lot in advance!

After some searching around, I have found this tutorial which answers my first question:
http://developer.playcanvas.com/en/tutorials/advanced/real-time-multiplayer/
It explains how to open a socket and communicate through it.

My second question (timer / scheduler) remains open.

Cheers!

setInterval(function () {
    talkToServer();
}, 200);

Reference Docs

Thanks Will!
I forgot that I can just use pure JS :slight_smile:

1 Like