[Twisted-Python] connecting with a FlashXML socket
Eric T
continuum83 at yahoo.com
Wed Mar 16 11:23:36 EST 2005
hey All,
my friend and i are attempting to use twisted as a
socket server to be able to accept connections from a
flash client.
here is the simple connection code on the serverside:
from twisted.protocols import basic
class TestApp(basic.LineReceiver):
def connectionMade(self):
print "new client\n"
self.factory.clients.append(self)
self.message("test")
self.sendLine("another test");
def connectionLost(self):
print "lost client\n"
self.factory.clients.remove(self)
def lineReceived(self,line):
print "recieved:", repr(line)
for c in self.factory.clients:
c.message(line)
def message(self,msg):
self.transport.write(msg + '\n')
print msg + '\n'
this is basically the same as an example we were using
to help us get the code going. but when we run the
server, and then go to the client... the client
connects fine, but we cannt send/recieve any messages.
we tried setting the self.delimiter = "\0" since that
is a requirement for flashXML, but it still wouldnt
send/recieve.
the socket code on the flash-side is relative to the
following:
mySocket = new XMLSocket();
mySocket.onConnect = function(success)
{
if (success)
msgArea.htmlText += ";<b>Server connection
established!</b>"
else
msgArea.htmlText += "<b>Server connection
failed!</b>"
}
mySocket.onClose = function()
{
msgArea.htmlText += "<b>Server connection lost</b>"
}
XMLSocket.prototype.onData = function(msg)
{
trace("MSG: " + msg)
msgArea.htmlText += msg
}
mySocket.connect("localhost", 9999)
function sendMsg()
{
mySocket.send(inputMsg.htmlText + "\n")
}
}
__________________________________
Do you Yahoo!?
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/
More information about the Twisted-Python
mailing list