comparison orpg/networking/mplay_server.py @ 124:8827271fbe1b alpha

Traipse Alpha 'OpenRPG' {091001-01} Traipse is a distribution of OpenRPG that is designed to be easy to setup and go. Traipse also makes it easy for developers to work on code without fear of sacrifice. 'Ornery-Orc' continues the trend of 'Grumpy' and adds fixes to the code. 'Ornery-Orc's main goal is to offer more advanced features and enhance the productivity of the user. Update Summary (Cleaning up for Beta) Added Bookmarks Fix to Remote Admin Commands Minor fix to text based Server Fix to Pretty Print, from Core Fix to Splitter Nodes not being created Fix to massive amounts of images loading, from Core Added 'boot' command to remote admin Added confirmation window for sent nodes Minor changes to allow for portability to an OpenSUSE linux OS Miniatures Layer pop up box allows users to turn off Mini labels, from FlexiRPG Zoom Mouse plugin added Images added to Plugin UI Switching to Element Tree Map efficiency, from FlexiRPG Added Status Bar to Update Manager default_manifest.xml renamed to default_upmana.xml Cleaner clode for saved repositories New TrueDebug Class in orpg_log (See documentation for usage) Mercurial's hgweb folder is ported to upmana Happy Halloween!
author sirebral
date Sun, 01 Nov 2009 11:36:14 -0600
parents 36919b8a3ef9
children fba298d65cf8
comparison
equal deleted inserted replaced
123:174658f839c0 124:8827271fbe1b
73 "converts strings to intergers for list sort comparisons for group and player ids so they end up in numeric order" 73 "converts strings to intergers for list sort comparisons for group and player ids so they end up in numeric order"
74 return cmp(int(a),int(b)) 74 return cmp(int(a),int(b))
75 75
76 76
77 class game_group(object): 77 class game_group(object):
78 debug()
79 def __init__(self, id, name, pwd, desc="", boot_pwd="", 78 def __init__(self, id, name, pwd, desc="", boot_pwd="",
80 minVersion="", mapFile=None, messageFile=None, persist=0): 79 minVersion="", mapFile=None, messageFile=None, persist=0):
81 self.id = id 80 self.id = id
82 self.name = name 81 self.name = name
83 self.desc = desc 82 self.desc = desc
102 tree = f.read() 101 tree = f.read()
103 f.close() 102 f.close()
104 self.game_map.init_from_xml(fromstring(tree)) 103 self.game_map.init_from_xml(fromstring(tree))
105 104
106 def save_map(self): 105 def save_map(self):
107 debug() 106 #debug(log=False)
108 if self.mapFile is not None and self.persistant == 1 and self.mapFile.find("default_map.xml") == -1: 107 if self.mapFile is not None and self.persistant == 1 and self.mapFile.find("default_map.xml") == -1:
109 f = open(self.mapFile, "w") 108 f = open(self.mapFile, "w")
110 f.write(self.game_map.get_all_xml()) 109 f.write(self.game_map.get_all_xml())
111 f.close() 110 f.close()
112 111
113 def add_player(self,id): 112 def add_player(self,id):
114 debug()
115 self.players.append(id) 113 self.players.append(id)
116 114
117 def remove_player(self,id): 115 def remove_player(self,id):
118 debug()
119 if self.voice.has_key(id): del self.voice[id] 116 if self.voice.has_key(id): del self.voice[id]
120 self.players.remove(id) 117 self.players.remove(id)
121 118
122 def get_num_players(self): 119 def get_num_players(self):
123 debug()
124 num = len(self.players) 120 num = len(self.players)
125 return num 121 return num
126 122
127 def get_player_ids(self): 123 def get_player_ids(self):
128 debug()
129 tmp = self.players 124 tmp = self.players
130 return tmp 125 return tmp
131 126
132 def check_pwd(self,pwd): 127 def check_pwd(self,pwd):
133 debug()
134 return (pwd==self.pwd) 128 return (pwd==self.pwd)
135 129
136 def check_boot_pwd(self,pwd): 130 def check_boot_pwd(self,pwd):
137 return (pwd==self.boot_pwd) 131 return (pwd==self.boot_pwd)
138 132
139 def check_version(self,ver): 133 def check_version(self,ver):
140 debug()
141 if (self.minVersion == ""): return 1 134 if (self.minVersion == ""): return 1
142 minVersion=self.minVersion.split('.') 135 minVersion=self.minVersion.split('.')
143 version=ver.split('.') 136 version=ver.split('.')
144 for i in xrange(min(len(minVersion),len(version))): 137 for i in xrange(min(len(minVersion),len(version))):
145 w=max(len(minVersion[i]),len(version[i])) 138 w=max(len(minVersion[i]),len(version[i]))
151 return 0 144 return 0
152 return 1 145 return 1
153 146
154 #depreciated - see send_group_list() 147 #depreciated - see send_group_list()
155 def toxml(self, act="new"): 148 def toxml(self, act="new"):
156 debug(self.name)
157 # Please don't add the boot_pwd to the xml, as this will give it away to players watching their console 149 # Please don't add the boot_pwd to the xml, as this will give it away to players watching their console
158 el = Element('group') 150 el = Element('group')
159 el.set('id', self.id) 151 el.set('id', self.id)
160 el.set('name', self.name) 152 el.set('name', self.name)
161 el.set('pwd', str(self.pwd!="")) 153 el.set('pwd', str(self.pwd!=""))
162 el.set('players', str(self.get_num_players())) 154 el.set('players', str(self.get_num_players()))
163 el.set('action', act) 155 el.set('action', act)
164 return tostring(el) 156 return tostring(el)
165 157
166 class client_stub(client_base): 158 class client_stub(client_base):
167 debug()
168 def __init__(self,inbox,sock,props,log): 159 def __init__(self,inbox,sock,props,log):
169 client_base.__init__(self) 160 client_base.__init__(self)
170 self.ip = props['ip'] 161 self.ip = props['ip']
171 self.role = props['role'] 162 self.role = props['role']
172 self.id = props['id'] 163 self.id = props['id']
194 diff = curtime - self.timeout_time 185 diff = curtime - self.timeout_time
195 if diff > 1800: return 1 186 if diff > 1800: return 1
196 else: return 0 187 else: return 0
197 188
198 def send(self, msg, player, group): 189 def send(self, msg, player, group):
199 debug()
200 if self.get_status() == MPLAY_CONNECTED: 190 if self.get_status() == MPLAY_CONNECTED:
201 #el = Element('msg') 191 #el = Element('msg')
202 #el.set('to', player) 192 #el.set('to', player)
203 #el.set('from', '0') 193 #el.set('from', '0')
204 #el.set('group_id', group) 194 #el.set('group_id', group)
205 #el.text(msg) 195 #el.text(msg)
206 self.outbox.put("<msg to='" + player + "' from='0' group_id='" + group + "' />" + msg) 196 self.outbox.put("<msg to='" + player + "' from='0' group_id='" + group + "' />" + msg)
207 197
208 def change_group(self, group_id, groups): 198 def change_group(self, group_id, groups):
209 debug()
210 old_group_id = str(self.group_id) 199 old_group_id = str(self.group_id)
211 groups[group_id].add_player(self.id) 200 groups[group_id].add_player(self.id)
212 groups[old_group_id].remove_player(self.id) 201 groups[old_group_id].remove_player(self.id)
213 self.group_id = group_id 202 self.group_id = group_id
214 self.outbox.put(self.toxml('group')) 203 self.outbox.put(self.toxml('group'))
234 ###################################################################### 223 ######################################################################
235 ###################################################################### 224 ######################################################################
236 """ 225 """
237 226
238 class mplay_server: 227 class mplay_server:
239 debug() 228 #debug(log=False)
240 def __init__(self, log_console=None, name=None): 229 def __init__(self, log_console=None, name=None):
241 logger._set_log_level = 16 230 logger._set_log_level = 16
242 logger._set_log_to_console(True) 231 logger._set_log_to_console(True)
243 self.log_to_console = 1 232 self.log_to_console = 1
244 self.log_console = log_console 233 self.log_console = log_console
272 self.allowRemoteKill = False 261 self.allowRemoteKill = False
273 self.allowRemoteAdmin = True 262 self.allowRemoteAdmin = True
274 self.sendLobbySound = False 263 self.sendLobbySound = False
275 self.lobbySound = 'http://www.digitalxero.net/music/mus_tavern1.bmu' ##used? 264 self.lobbySound = 'http://www.digitalxero.net/music/mus_tavern1.bmu' ##used?
276 265
277 @debugging
278 def initServer(self, **kwargs): 266 def initServer(self, **kwargs):
267 #debug(log=False)
279 for atter, value in kwargs.iteritems(): setattr(self, atter, value) 268 for atter, value in kwargs.iteritems(): setattr(self, atter, value)
280 validate.config_file( self.lobbyMapFile, "default_Lobby_map.xml" ) 269 validate.config_file( self.lobbyMapFile, "default_Lobby_map.xml" )
281 validate.config_file( self.lobbyMessageFile, "default_LobbyMessage.html" ) 270 validate.config_file( self.lobbyMessageFile, "default_LobbyMessage.html" )
282 self.server_start_time = time.time() 271 self.server_start_time = time.time()
283 272
365 except Exception, e: 354 except Exception, e:
366 self.log_msg("Exception in saveBanList() " + str(e)) 355 self.log_msg("Exception in saveBanList() " + str(e))
367 356
368 # This method reads in the server's configuration file and reconfigs the server 357 # This method reads in the server's configuration file and reconfigs the server
369 # as needed, over-riding any default values as requested. 358 # as needed, over-riding any default values as requested.
359
370 def initServerConfig(self): 360 def initServerConfig(self):
361 #debug(log=False)
371 self.log_msg("Processing Server Configuration File... " + self.userPath) 362 self.log_msg("Processing Server Configuration File... " + self.userPath)
372 # make sure the server_ini.xml exists! 363 # make sure the server_ini.xml exists!
373 validate.config_file( "server_ini.xml", "default_server_ini.xml" ) 364 validate.config_file( "server_ini.xml", "default_server_ini.xml" )
374 # try to use it. 365 # try to use it.
375 try: 366 try:
664 badchars = "\"\\`><" 655 badchars = "\"\\`><"
665 for c in badchars: name = name.replace(c,"") 656 for c in badchars: name = name.replace(c,"")
666 return name 657 return name
667 658
668 def registerRooms(self, args=None): 659 def registerRooms(self, args=None):
660 #debug()
669 rooms = '' 661 rooms = ''
670 id = '0' 662 id = '0'
671 time.sleep(500) 663 time.sleep(500)
664 #debug(self.groups)
672 for rnum in self.groups.keys(): 665 for rnum in self.groups.keys():
673 rooms += urllib.urlencode( {"room_data[rooms][" + str(rnum) + "][name]":self.groups[rnum].name, 666 rooms += urllib.urlencode( {"room_data[rooms][" + str(rnum) + "][name]":self.groups[rnum].name,
674 "room_data[rooms][" + str(rnum) + "][pwd]":str(self.groups[rnum].pwd != "")})+'&' 667 "room_data[rooms][" + str(rnum) + "][pwd]":str(self.groups[rnum].pwd != "")})+'&'
675 for pid in self.groups[rnum].players: 668 for pid in self.groups[rnum].players:
676 rooms += urllib.urlencode( {"room_data[rooms][" + str(rnum) + "][players]["+str(pid)+"]":self.players[pid].name,})+'&' 669 rooms += urllib.urlencode( {"room_data[rooms][" + str(rnum) + "][players]["+str(pid)+"]":self.players[pid].name,})+'&'
670 #debug(rooms)
677 for meta in self.metas.keys(): 671 for meta in self.metas.keys():
678 while id == '0': 672 while id == '0':
679 id, cookie = self.metas[meta].getIdAndCookie() 673 id, cookie = self.metas[meta].getIdAndCookie()
680 data = urllib.urlencode( {"room_data[server_id]":id, 674 data = urllib.urlencode( {"room_data[server_id]":id,
681 "act":'registerrooms'}) 675 "act":'registerrooms'})
682 get_server_dom(data+'&'+rooms, self.metas[meta].path) 676 #debug((data, rooms))
677 get_server_dom(data+'&'+rooms, self.metas[meta].path, string=True)
683 678
684 def register(self,name_given=None): 679 def register(self,name_given=None):
685 if name_given == None: name = self.name 680 if name_given == None: name = self.name
686 else: self.name = name = name_given 681 else: self.name = name = name_given
687 name = self.clean_published_servername(name) 682 name = self.clean_published_servername(name)
910 print "'lobbysound' - Lets you specify which sound file to send to players joining the lobby" 905 print "'lobbysound' - Lets you specify which sound file to send to players joining the lobby"
911 print "'help' or '?' or 'h' - for this help message" 906 print "'help' or '?' or 'h' - for this help message"
912 print 907 print
913 908
914 def broadcast(self,msg): 909 def broadcast(self,msg):
915 self.send_to_all("0","<msg to='all' from='0' group_id='1'><font color='#FF0000'>" + msg + "</font>") 910 self.send_to_all("0","<msg to='all' from='0' group_id='1'><font color='#FF0000'>" + msg + "</font></msg>")
916 911
917 def console_log(self): 912 def console_log(self):
918 if self.log_to_console == 1: 913 if self.log_to_console == 1:
919 print "console logging now off" 914 print "console logging now off"
920 self.log_to_console = 0 915 self.log_to_console = 0
969 elif self.players[id].group_id.find(patern)>-1: self.print_player_info(self.players[id]) 964 elif self.players[id].group_id.find(patern)>-1: self.print_player_info(self.players[id])
970 elif self.players[id].role.find(patern)>-1: self.print_player_info(self.players[id]) 965 elif self.players[id].role.find(patern)>-1: self.print_player_info(self.players[id])
971 elif self.players[id].version.find(patern)>-1: self.print_player_info(self.players[id]) 966 elif self.players[id].version.find(patern)>-1: self.print_player_info(self.players[id])
972 elif self.players[id].protocol_version.find(patern)>-1: self.print_player_info(self.players[id]) 967 elif self.players[id].protocol_version.find(patern)>-1: self.print_player_info(self.players[id])
973 elif self.players[id].client_string.find(patern)>-1: self.print_player_info(self.players[id]) 968 elif self.players[id].client_string.find(patern)>-1: self.print_player_info(self.players[id])
969
970 def obtain_by_id(self, id, objects):
971 ### Alpha ### Basic way to obtain information for the Server GUI, currently reports the Client String only
972 return self.players[id].client_string
974 973
975 def print_player_info(self,player): 974 def print_player_info(self,player):
976 print player.id, player.name, player.ip, player.group_id, player.role, player.version, player.protocol_version, player.client_string 975 print player.id, player.name, player.ip, player.group_id, player.role, player.version, player.protocol_version, player.client_string
977 976
978 """ 977 """
1255 if v1>v2: return 0 1254 if v1>v2: return 0
1256 if len(minv)>len(cver): return 0 1255 if len(minv)>len(cver): return 0
1257 return 1 1256 return 1
1258 1257
1259 def SendLobbyMessage(self, socket, player_id): 1258 def SendLobbyMessage(self, socket, player_id):
1260 debug() 1259 #debug(log=False)
1261 """ 1260 """
1262 # Display the lobby message 1261 # Display the lobby message
1263 # prepend this server's version string to the the lobby message 1262 # prepend this server's version string to the the lobby message
1264 """ 1263 """
1265 try: 1264 try:
1327 # At this point, we're done and cleaning up. 1326 # At this point, we're done and cleaning up.
1328 self.log_msg("server socket listening thread exiting...") 1327 self.log_msg("server socket listening thread exiting...")
1329 self.listen_event.set() 1328 self.listen_event.set()
1330 1329
1331 def acceptedNewConnectionThread( self, newsock, addr ): 1330 def acceptedNewConnectionThread( self, newsock, addr ):
1332 debug() 1331 #debug(log=False)
1333 """Once a new connection comes in and is accepted, this thread starts up to handle it.""" 1332 """Once a new connection comes in and is accepted, this thread starts up to handle it."""
1334 # Initialize xml_dom 1333 # Initialize xml_dom
1335 xml_dom = None 1334 xml_dom = None
1336 data = None 1335 data = None
1337 1336
1388 print "from " + str(addr) + " created the following exception: " 1387 print "from " + str(addr) + " created the following exception: "
1389 traceback.print_exc() 1388 traceback.print_exc()
1390 return #returning causes connection thread instance to terminate 1389 return #returning causes connection thread instance to terminate
1391 1390
1392 # Again attempt to clean out DOM stuff 1391 # Again attempt to clean out DOM stuff
1393 try: 1392 """
1394 if xml_dom: xml_dom.unlink() 1393 try: if xml_dom: xml_dom.unlink()
1395 except: 1394 except:
1396 print "The following exception caught unlinking xml_dom:" 1395 print "The following exception caught unlinking xml_dom:"
1397 traceback.print_exc() 1396 traceback.print_exc()
1398 return #returning causes connection thread instance to terminate 1397 return #returning causes connection thread instance to terminate"""
1399 1398
1400 """ 1399 """
1401 #======================================================== 1400 #========================================================
1402 # 1401 #
1403 # Message_handler 1402 # Message_handler
1408 # to multiple expiring parsing/handling threads to improve server performance 1407 # to multiple expiring parsing/handling threads to improve server performance
1409 # and player load capacity -- Snowdog 3/04 1408 # and player load capacity -- Snowdog 3/04
1410 """ 1409 """
1411 1410
1412 def message_handler(self, arg): 1411 def message_handler(self, arg):
1413 debug() 1412 #debug(log=False)
1414 xml_dom = None 1413 xml_dom = None
1415 self.log_msg( "message handler thread running..." ) 1414 self.log_msg( "message handler thread running..." )
1416 while self.alive: 1415 while self.alive:
1417 data = None 1416 data = None
1418 try: data=self.incoming.get(0) 1417 try: data=self.incoming.get(0)
1434 #if xml_dom: xml_dom.unlink() 1433 #if xml_dom: xml_dom.unlink()
1435 self.log_msg("message handler thread exiting...") 1434 self.log_msg("message handler thread exiting...")
1436 self.incoming_event.set() 1435 self.incoming_event.set()
1437 1436
1438 def parse_incoming_dom(self,data): 1437 def parse_incoming_dom(self,data):
1439 debug(data)
1440 end = data.find(">") #locate end of first element of message 1438 end = data.find(">") #locate end of first element of message
1441 head = data[:end+1] 1439 head = data[:end+1]
1442 #self.log_msg(head) 1440 #self.log_msg(head)
1443 xml_dom = None 1441 xml_dom = None
1444 try: 1442 try:
1450 print "Error in parse of inbound message. Ignoring message." 1448 print "Error in parse of inbound message. Ignoring message."
1451 print " Offending data(" + str(len(data)) + "bytes)=" + data 1449 print " Offending data(" + str(len(data)) + "bytes)=" + data
1452 print "Exception=" + str(e) 1450 print "Exception=" + str(e)
1453 1451
1454 def message_action(self, xml_dom, data): 1452 def message_action(self, xml_dom, data):
1455 debug() 1453 tag_name = xml_dom.tag
1456 tag_name = xml_dom.tag; print 'message_action tag_name', tag_name
1457 if self.svrcmds.has_key(tag_name): self.svrcmds[tag_name]['function'](xml_dom, data) 1454 if self.svrcmds.has_key(tag_name): self.svrcmds[tag_name]['function'](xml_dom, data)
1458 else: raise Exception, "Not a valid header!" 1455 else: raise Exception, "Not a valid header!"
1459 #Message Action thread expires and closes here. 1456 #Message Action thread expires and closes here.
1460 return 1457 return
1461 1458
1462 def do_alter(self, xml_dom, data): 1459 def do_alter(self, xml_dom, data):
1463 debug()
1464 target = xml_dom.get("key") 1460 target = xml_dom.get("key")
1465 value = xml_dom.get("val") 1461 value = xml_dom.get("val")
1466 player = xml_dom.get("plr") 1462 player = xml_dom.get("plr")
1467 group_id = xml_dom.get("gid") 1463 group_id = xml_dom.get("gid")
1468 boot_pwd = xml_dom.get("bpw") 1464 boot_pwd = xml_dom.get("bpw")
1490 else: 1486 else:
1491 msg ="<msg to='" + player + "' from='0' group_id='0'>Invalid Administrator Password." 1487 msg ="<msg to='" + player + "' from='0' group_id='0'>Invalid Administrator Password."
1492 self.players[player].outbox.put(msg) 1488 self.players[player].outbox.put(msg)
1493 1489
1494 def do_role(self, xml_dom, data): 1490 def do_role(self, xml_dom, data):
1495 debug()
1496 role = "" 1491 role = ""
1497 boot_pwd = "" 1492 boot_pwd = ""
1498 act = xml_dom.get("action") 1493 act = xml_dom.get("action")
1499 player = xml_dom.get("player") 1494 player = xml_dom.get("player")
1500 group_id = xml_dom.get("group_id") 1495 group_id = xml_dom.get("group_id")
1505 if group_id != "0": 1500 if group_id != "0":
1506 self.handle_role(act, player, role, boot_pwd, group_id) 1501 self.handle_role(act, player, role, boot_pwd, group_id)
1507 self.log_msg(("role", (player, role))) 1502 self.log_msg(("role", (player, role)))
1508 1503
1509 def do_ping(self, xml_dom, data): 1504 def do_ping(self, xml_dom, data):
1510 debug()
1511 player = xml_dom.get("player") 1505 player = xml_dom.get("player")
1512 group_id = xml_dom.get("group_id") 1506 group_id = xml_dom.get("group_id")
1513 sent_time = "" 1507 sent_time = ""
1514 msg = "" 1508 msg = ""
1515 try: sent_time = xml_dom.get("time") 1509 try: sent_time = xml_dom.get("time")
1520 msg += "<font color='#FF0000'>PONG!?!</font>" 1514 msg += "<font color='#FF0000'>PONG!?!</font>"
1521 self.players[player].outbox.put(msg) 1515 self.players[player].outbox.put(msg)
1522 #xml_dom.unlink() 1516 #xml_dom.unlink()
1523 1517
1524 def do_system(self, xml_dom, data): 1518 def do_system(self, xml_dom, data):
1525 debug()
1526 pass 1519 pass
1527 1520
1528 def moderate_group(self,xml_dom,data): 1521 def moderate_group(self,xml_dom,data):
1529 try: 1522 try:
1530 action = xml_dom.get("action") 1523 action = xml_dom.get("action")
1662 thread.start_new_thread(self.registerRooms,(0,)) 1655 thread.start_new_thread(self.registerRooms,(0,))
1663 1656
1664 def return_room_roles(self, from_id, group_id): 1657 def return_room_roles(self, from_id, group_id):
1665 for m in self.players.keys(): 1658 for m in self.players.keys():
1666 if self.players[m].group_id == group_id: 1659 if self.players[m].group_id == group_id:
1667 print 'return_room_roles', self.players[m].id, self.players[m].role, self.players[m]
1668 try: msg = "<role action='update' id='" + self.players[m].id + "' role='" + self.players[m].role + "' />" 1660 try: msg = "<role action='update' id='" + self.players[m].id + "' role='" + self.players[m].role + "' />"
1669 except: exit() 1661 except: exit()
1670 self.players[from_id].outbox.put(msg) 1662 self.players[from_id].outbox.put(msg)
1671 1663
1672 """ 1664 """
1727 return lmessage 1719 return lmessage
1728 except: return "An error occured during rename of room!" 1720 except: return "An error occured during rename of room!"
1729 thread.start_new_thread(self.registerRooms,(0,)) 1721 thread.start_new_thread(self.registerRooms,(0,))
1730 1722
1731 def create_group(self, xml_dom, data): 1723 def create_group(self, xml_dom, data):
1732 debug((tostring(xml_dom), data))
1733 #try: 1724 #try:
1734 from_id = xml_dom.get("from") 1725 from_id = xml_dom.get("from")
1735 pwd = xml_dom.get("pwd") 1726 pwd = xml_dom.get("pwd")
1736 name = xml_dom.get("name") 1727 name = xml_dom.get("name")
1737 boot_pwd = xml_dom.get("boot_pwd") 1728 boot_pwd = xml_dom.get("boot_pwd")
1838 self.register() 1829 self.register()
1839 except Exception, e: self.log_msg(str(e)) 1830 except Exception, e: self.log_msg(str(e))
1840 self.log_msg("Explicit garbage collection shows %s undeletable items." % str(gc.collect())) 1831 self.log_msg("Explicit garbage collection shows %s undeletable items." % str(gc.collect()))
1841 1832
1842 def incoming_player_handler(self, xml_dom, data): 1833 def incoming_player_handler(self, xml_dom, data):
1843 debug()
1844 id = xml_dom.get("id") 1834 id = xml_dom.get("id")
1845 act = xml_dom.get("action") 1835 act = xml_dom.get("action")
1846 #group_id = xml_dom.get("group_id") 1836 #group_id = xml_dom.get("group_id")
1847 group_id = self.players[id].group_id 1837 group_id = self.players[id].group_id
1848 ip = self.players[id].ip 1838 ip = self.players[id].ip
1856 except Exception, e: traceback.print_exc() 1846 except Exception, e: traceback.print_exc()
1857 elif act=="del": 1847 elif act=="del":
1858 self.del_player(id,group_id) 1848 self.del_player(id,group_id)
1859 self.check_group(id, group_id) 1849 self.check_group(id, group_id)
1860 elif act=="update": 1850 elif act=="update":
1861 debug(xml_dom)
1862 print xml_dom.get('name')
1863 self.players[id].take_dom(xml_dom) 1851 self.players[id].take_dom(xml_dom)
1864 self.log_msg(("update", {"id": id, 1852 self.log_msg(("update", {"id": id,
1865 "name": xml_dom.get("name"), 1853 "name": xml_dom.get("name"),
1866 "status": xml_dom.get("status"), 1854 "status": xml_dom.get("status"),
1867 "role": xml_dom.get("role"), 1855 "role": xml_dom.get("role"),
1890 def msgTooLong(self, length): 1878 def msgTooLong(self, length):
1891 if length > self.maxSendSize and not self.maxSendSize == 0: return True 1879 if length > self.maxSendSize and not self.maxSendSize == 0: return True
1892 return False 1880 return False
1893 1881
1894 def incoming_msg_handler(self,xml_dom,data): 1882 def incoming_msg_handler(self,xml_dom,data):
1895 debug()
1896 xml_dom, data = ServerPlugins.preParseIncoming(xml_dom, data) 1883 xml_dom, data = ServerPlugins.preParseIncoming(xml_dom, data)
1897 ########################################################### 1884 ###########################################################
1898 to_id = xml_dom.get("to") 1885 to_id = xml_dom.get("to")
1899 from_id = xml_dom.get("from") 1886 from_id = xml_dom.get("from")
1900 group_id = xml_dom.get("group_id") 1887 group_id = xml_dom.get("group_id")
1940 else: self.players[to_id].outbox.put(data) 1927 else: self.players[to_id].outbox.put(data)
1941 self.check_group_members(group_id) 1928 self.check_group_members(group_id)
1942 return 1929 return
1943 1930
1944 def sound_msg_handler(self, xml_dom, data): 1931 def sound_msg_handler(self, xml_dom, data):
1945 debug()
1946 from_id = xml_dom.get("from") 1932 from_id = xml_dom.get("from")
1947 group_id = xml_dom.get("group_id") 1933 group_id = xml_dom.get("group_id")
1948 if group_id != 0: self.send_to_group(from_id, group_id, data) 1934 if group_id != 0: self.send_to_group(from_id, group_id, data)
1949 1935
1950 def plugin_msg_handler(self,xml_dom,data): 1936 def plugin_msg_handler(self,xml_dom,data):
2207 def send(self,msg,player,group): 2193 def send(self,msg,player,group):
2208 self.players[player].send(msg,player,group) 2194 self.players[player].send(msg,player,group)
2209 2195
2210 def send_to_all(self,from_id,data): 2196 def send_to_all(self,from_id,data):
2211 try: 2197 try:
2212 print data
2213 self.p_lock.acquire() 2198 self.p_lock.acquire()
2214 keys = self.players.keys() 2199 keys = self.players.keys()
2215 self.p_lock.release() 2200 self.p_lock.release()
2216 for k in keys: 2201 for k in keys:
2217 if k != from_id: self.players[k].outbox.put(data) 2202 if k != from_id: self.players[k].outbox.put(data)