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

Richard Strong sidius at ucla.edu
Wed Jun 28 14:22:06 EDT 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 

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):
       #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!" />')
       return ""      
   def lineReceived(self,line):
       if line == "<policy-file-request/>":
           print "\t sending policy file"
version=\"1.0\"?><cross-domain-policy><allow-access-from domain=\"*\" 
to-ports=\"8007\" /></cross-domain-policy>")
           #bistBlast.bistBlast.__init__(self, 8009)
                     print "LINE RECEIVED"
               bistBlast.bistBlast.__init__(self, 8009)
               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)

More information about the Twisted-Python mailing list