2019-01-22 01:30:42 +01:00
|
|
|
import socket
|
2019-01-23 10:28:23 +01:00
|
|
|
import threading
|
2020-05-27 15:45:58 +02:00
|
|
|
import time
|
2019-01-22 01:30:42 +01:00
|
|
|
|
|
|
|
|
|
|
|
class MasterServer:
|
|
|
|
def __init__(self, server):
|
|
|
|
self.server = server
|
|
|
|
self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
|
|
|
self.masterserverip = "gckms.no-ip.org"
|
|
|
|
self.masterserverport = 27900
|
|
|
|
|
|
|
|
def register_and_run(self):
|
2020-05-27 15:45:58 +02:00
|
|
|
register_thread = threading.Thread(target=self._register)
|
|
|
|
register_thread.start()
|
|
|
|
return register_thread
|
2019-01-22 01:30:42 +01:00
|
|
|
|
2019-01-23 10:28:23 +01:00
|
|
|
def _register(self):
|
2019-01-22 01:30:42 +01:00
|
|
|
while True:
|
2020-05-27 15:45:58 +02:00
|
|
|
self.socket.sendto(("0"+str(self.server.listen_port)).encode("ascii"), (self.masterserverip, self.masterserverport))
|
|
|
|
time.sleep(120)
|