Commit a4c95fe9 authored by minus's avatar minus

refactored servercount example

parent 50562358
from teeworlds import query_masters_servercount, create_masters, EventSocket
#!/usr/bin/env python3
from teeworlds import query_masters_servercount, create_masters, EventSocket, MasterServer
class CountingMasterServer(MasterServer):
total_count = 0
def on_count_receive(self, count):
CountingMasterServer.total_count += count
e = EventSocket()
m = create_masters(e)
m = create_masters(e, master_factory=CountingMasterServer)
query_masters_servercount(m)
#for m in t.masterlist:
# m.on_server_add = lambda s: s.request_info()
#t.query_masters()
e.run()
print(CountingMasterServer.total_count)
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment