Hello all. You might remember me @overtorment, when you released noobhub I was one of the first few guys to start using it. I’ve got comments all over the original noobhub thread. Anyways, noobhub has worked great in my children’s game “Math Race Online” since late August w/ the exception of the small bug where node would catch an error and end the script. Since you fixed that and released the new nodejs a few months back, the script has literally been running for 2 months straight without a single restart, which is fantastic! I’m using noobhub in a new project, and I am running into a small barrier. The app has to keep time in sync between the user and the host. so if a user joins a room, and the game is at 25 minutes 30 seconds and 873 milliseconds, the host has to send that time to the user and the user needs to know (almost) exactly how long ago the host send that number, so that say if the host sends to the user:
Time: 18 minutes, 3 seconds, 322 milliseconds,
then when the user receives that pong, I need the user to know how many milliseconds ago the request was sent so that the number of milliseconds of latency can be removed from the actual time sent by the host so that the host and the user are in sync.
My question is, is there anything built into noobhub that tells you what the latency of a ping/pong was? I thought about just having the host send a (1) ping, storing the system.getTimer() when the ping was sent, then (2) when the client receives this ping, pong the host back acknowledging ping received. then the host can substract the new system.getTimer() from the old one when the ping was sent, and divide that by 2 and send that to the client notifying them that is the latency in milliseconds. Obviously this wouldn’t be fully accurate, but I was in a rush when I thought of it. If there isn’t anything built in to tell latency, does anyone have any suggestions of ways this could be custom coded?
Note: the time has to be in milliseconds, not seconds.
Thanks!
Tyler