[Twisted-Python] Creating a proxy between a flash client and xmlBlaster

Richard Strong sidius at ucla.edu
Wed Jun 28 12:22:06 MDT 2006


Hi all,

I am attempting to build a proxy between xmlBlaster and a Flash client 
using an XmlSocket on the client side.
My cludge was going to be the twisted library. Essentially I want to 
have the update function of xmlBlaster
call basic.LineReceiver.sendLine(...) and the lineReceived function of 
twisted to call self.msgPublish.
I have a through line working from the Flash client to xmlBlaster, but 
cannot get a message from
xmlBlaster to Flash (even after a Flash client has successfully logged 
in.). Any help would be
divine.  Here is a copy of the source code for the server that has been 
created:

from const import *
import sys
import os
import time
import signal
import threading
sys.path.insert(0, CLIENTPATH)
import bistBlast
from twisted.protocols import basic
from twisted.internet import reactor, protocol
from twisted.internet.protocol import Protocol

class Proxy(bistBlast.bistBlast,basic.LineReceiver, threading.Thread):
   delimiter = '\0'
   def __init__(self):
             print 
"init======================================================>"
       #bistBlast.bistBlast.__init__(self, 8009)

                     def update(self, sessionId, key, content, qos):
       print """__recieved message__ """
           print "__key__", key
           print "__content__\n", content.data
           print "__qos__", qos
       #print ""
       self.sendLine('<MESSAGE USER="John" TEXT="Hello, my name is 
John!" />')
       #self.message('<MESSAGE USER="John" TEXT="Hello, my name is 
John!" />')
       #self.sendLine(key)
       return ""      
   def lineReceived(self,line):
 
       if line == "<policy-file-request/>":
           print "\t sending policy file"
           self.sendLine("<?xml 
version=\"1.0\"?><cross-domain-policy><allow-access-from domain=\"*\" 
to-ports=\"8007\" /></cross-domain-policy>")
           #bistBlast.bistBlast.__init__(self, 8009)
           #self.msgSubscribe("test")
       else:
                     print "LINE RECEIVED"
           try:
               bistBlast.bistBlast.__init__(self, 8009)
               self.msgSubscribe("test")
           except:
               print "already connected"
           self.msgPublish("<key oid='test' />", "<what />")
           self.sendLine('<MESSAGE USER="John" TEXT="Hello, my name is 
John!" />')

   def sendLine(self, msg):
       print "Sending Message"
       basic.LineReceiver.sendLine(self, msg)
       print "Sent Message"
         def message(self, msg):
       self.transport.write(msg + '\n' + delimiter)
       print msg + '\n'
      # Main
if __name__ == '__main__':

   ProxyFactory = protocol.ServerFactory()
   ProxyFactory.protocol = Proxy
   reactor.listenTCP(8007, ProxyFactory)
   reactor.run()




More information about the Twisted-Python mailing list