[Spread-users] connecting to spread with Flash

Jonathan Stanton jonathan at cnds.jhu.edu
Thu May 12 12:03:10 EDT 2005


Hi,

They key question seems to be what flash detects as the 'end' of a 
message. If by '0 byte' you mean that a blocking 'read' on teh socket 
returns 0 bytes indicting the socket connection has closed, then that 
will not work with spread. 

Spread opens one tcp connection between the client and server and then
keeps that conenction open until the client calls SP_disconnect or there
is a network fault. Each Spread message (whether part of the connect
sequence, or a distinct data message) is sent on that same tcp
connection. 

If this XMLsocket is built on the HTTP type model where a new tcp 
connection is established for each data exchange, then that's just not 
going to work. Spread is designed for long-term communication of many 
messages between principles. 

If there is a way to control when XMLSocket calls the callback you could
code in knowledge of when a complete spread message is received (the
format of the messages can be determined from the java code that reads
it in and most of it is fixed sized byte arrays so calculating how many
bytes to receive isn't too hard) The Spread server does not 'send' any
signal for end of message, it relies on both ends knowing the message
format and calculating when a complete message has arrived. 

Hope this all makes sense, even if it sounds like negative news. I don't 
konw Flash at all, so there might be other ways to do this.

Cheers,

Jonathan


On Thu, May 05, 2005 at 03:26:37PM +0530, Francis Chary wrote:
> Hi there,
> 
> I'm trying to connect to a spread server with an application written in 
> Actionscript (The language behind Macromedia Flash). I'm essentially porting 
> the java spread client to actionscript as closely as I can, but I'm running 
> into a few problems. I know next-to-nothing about c, so looking at the 
> spread source code hasn't helped me so much.
> 
> The key difference between java and actionscript as I see it is that the AS 
> XMLSocket object doesn't allow you any access to the lower-level socket 
> streams. You only get two callback methods which are called when the socket 
> recieves some data. You have to put your data handling code in one of these 
> callbacks, and wait for data to come in. Conceptually, this isn't a problem 
> for the porting, I can work around it. The problem seems to be that 
> XMLSocket isn't 'noticing' when data is sent to it, and the callback isn't 
> being called at all. I assume that it has to do with Flash not realising 
> that a stream of data has been terminated. Flash looks for a 0 byte to 
> terminate a stream, is that what the spread server sends? 
> 
> I guess what I'm looking for is the communication that happens in the 
> sendConnect, readAuthMethods and sendAuthMethod methods of the Java client, 
> from the server's point of view. I hope this all makes sense.
> 
> Thanks
> Francis Chary
> 
> -- 
> Software Development Intern
> ABB Corporate Research
> 4th Floor, East Wing, Khanija Bhavan
> 49, Race Course Road
> Bangalore 560 001 India

> _______________________________________________
> Spread-users mailing list
> Spread-users at lists.spread.org
> http://lists.spread.org/mailman/listinfo/spread-users


-- 
-------------------------------------------------------
Jonathan R. Stanton         jonathan at cs.jhu.edu
Dept. of Computer Science   
Johns Hopkins University    
-------------------------------------------------------




More information about the Spread-users mailing list