changeset 566:cb68a426b486

hopefully this corrects some backward compatibility issues for new clients vs old server (for the plugin message but not sure how other messages manage to work)
author davidbyron
date Sun, 11 Apr 2010 16:40:00 -0500
parents 7e109dc95f24
children 6e5caf294011
files orpg/networking/mplay_client.py orpg/networking/mplay_messaging.py plugins/xxblank.py
diffstat 3 files changed, 14 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/orpg/networking/mplay_client.py	Sun Apr 11 11:32:26 2010 -0500
+++ b/orpg/networking/mplay_client.py	Sun Apr 11 16:40:00 2010 -0500
@@ -667,7 +667,7 @@
         if len(data) < 5:
             return
 
-        el = messaging.parse(data)
+        el = messaging.client_parse(data)
 
         id = el.get('from') or el.get('id', '0')
         # see if we are ignoring this user
--- a/orpg/networking/mplay_messaging.py	Sun Apr 11 11:32:26 2010 -0500
+++ b/orpg/networking/mplay_messaging.py	Sun Apr 11 16:40:00 2010 -0500
@@ -62,7 +62,18 @@
             except ExpatError:
                 el.text = msg
                 logger.general("Bad Message: \n" + raw_msg)
+        return el
 
+    def client_parse(self, raw_msg):
+        try:
+            el = fromstring(raw_msg)
+        except ExpatError:
+            #Backwards compatibility crap
+            try:
+                end =raw_msg.rfind("<")
+                el = fromstring(raw_msg[:end])
+            except ExpatError:
+                logger.general("Bad Message: \n" + raw_msg)
         return el
 
 messaging = MessageingClass()
\ No newline at end of file
--- a/plugins/xxblank.py	Sun Apr 11 11:32:26 2010 -0500
+++ b/plugins/xxblank.py	Sun Apr 11 16:40:00 2010 -0500
@@ -119,6 +119,8 @@
         dlg.Destroy()
 
     def on_xml_recive(self,id, xml_dom):
+        #To this work you will need to have two clients each with the plugin loaded.
+        #Then send a message using "/test balh blah blah" from one to the other.
         data = tostring(xml_dom)
         self.chat.InfoPost(self.name + ":: Message recived<br />" + data.replace("<","&lt;").replace(">","&gt;") +'<br />From id:' + str(id))