[SOLVED]How to ping an IP and display the latency ?

Get help using Construct 2

Post » Thu Jan 14, 2016 3:29 pm

Hi, guys i'm working on a small app, and i'd like it to show the latency of a server.

Is there any way to make construct ping the IP automatically and display it ?

Or do i have to make C2 execute a bat file with a "/ping xxx.xxx.xx.xxxx" command, make it write the reseult on a .txt and import the .txt into construct ?
Last edited by nkay on Fri Jan 15, 2016 1:18 am, edited 1 time in total.
B
6
S
1
Posts: 13
Reputation: 380

Post » Thu Jan 14, 2016 7:46 pm

If it´s for a server that you owne, you could make a PHP file that responds an "ok".
Construct side, you starts a timer when request it. Receiving de "ok", you have the "ping". It´s a "console" ping, but it´s the time that your request took to receive the "ok".
B
18
S
4
G
1
Posts: 143
Reputation: 1,868

Post » Fri Jan 15, 2016 1:13 am

no, it's not a server i own, but anyway i found how to do it with the AJAX and NWjs

for those who could need it, this is how i did :

1- create a .bat file with the ping and set an output text file "ping xxx.xxx.xx.xxx -n 1 > test.txt"
(don't forget to add the options you want in the .bat to only write in the .txt the data you want)

2- import both files in your construct 2 files folder (right click > import files)

3- add the AJAX object then make an action to create 2 AJAX requests on "Request URL", one for the .bat (batTAG) and another for the .txt (txtTAG)

4-add an action AJAX request "batTAG" on completed > NWjs run file yourbat.bat

5-add an action AJAX request "txtTAG" on completed > set text to AJAX.lastdata

if that's confusing this screenshoot should help:
Image
B
6
S
1
Posts: 13
Reputation: 380


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 5 guests