-
Notifications
You must be signed in to change notification settings - Fork 0
/
game_client.py
48 lines (44 loc) · 1.25 KB
/
game_client.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#import xmlrpc.client
#from xmlrpc.server import *
from _thread import start_new_thread
#import hashlib
#import sys
import time
import Pyro4
from Pyro4 import threadutil
class Chatter(object):
def __init__(self):
#self.game = Pyro4.core.Proxy("PYRO:Game@localhost:35674")
self.game = Pyro4.core.Proxy("PYRO:[email protected]:35674")
self.exit = False
def sys(self,msg):
print(msg)
def start(self):
si = self.game.get_sector_info()
print(si)
ui = self.game.join("rrr","n",self)
print(ui)
class DaemonThread(threadutil.Thread):
def __init__(self):
threadutil.Thread.__init__(self)
#self.chatter = chatter
self.setDaemon(True)
#daemon.register(self.chatter)
def run(self):
chatter.start()
"""with Pyro4.core.Daemon() as daemon:
print("registered object")
daemon.requestLoop(lambda: not self.chatter.exit)
"""
"""daemon = Pyro4.core.Daemon()
daemon.register(self.chatter)
daemon.requestLoop(lambda: not self.chatter.exit)
"""
chatter = Chatter()
daemon = Pyro4.core.Daemon(host="localhost",port=35675)
print(daemon.locationStr)
print(daemon.natLocationStr)
daemon.register(chatter)
daemonthread=DaemonThread()
daemonthread.start()
daemon.requestLoop(lambda: not chatter.exit)