diff options
Diffstat (limited to 'QueryServer.py')
-rwxr-xr-x | QueryServer.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/QueryServer.py b/QueryServer.py index 52e4aa0..fb2efd1 100755 --- a/QueryServer.py +++ b/QueryServer.py @@ -1,5 +1,7 @@ #!/usr/bin/env python3 +import time + # Time to live for caching. 0 to disable caching CACHE_TTL = 15 @@ -71,6 +73,7 @@ class QueryServer(): if gameid in sourcequeryinc: port += 1 + starttime = time.time() conn = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) message = None @@ -89,7 +92,10 @@ class QueryServer(): finally: conn.close() - data = dict() + data = {} + + latency = time.time() - starttime + data['latency'] = int(latency * 1000) # [0]-[3] -> 4*\xFF data['header'] = chr(message[4]) |