Groups | Blog | Home
all groups > macromedia flash flashcom > may 2005 >

macromedia flash flashcom : XML stream on the FCS without Remoting


agorman
5/19/2005 11:35:16 PM
I'm facing the dilemma of wanting the FCS to receive a stream of XML messages
from an external system. (The external system waits for socket connections then
streams XML messages. It runs on the same machine as the FCS). When I found out
that server-side AS doesn't support the XMLSocket object, I considered a quick
workaround (this is for a proof of concept prototype). I am considering
creating a client application (flash movie) that runs on the server. The
client-side code can open a socket to receive the incoming xml stream and then
publish the stream (with a NetStream object) to the server. Will this work?
Does anyone have any other suggestions?
JeffreyGong
6/2/2005 12:00:00 AM
I am thinking you may use FCS's shared object to pass XML string and use its onStatus() to handle evnets.

Jeffrey
agorman
6/2/2005 12:00:00 AM
My issue was not so much the XML, but it was getting a stream of data to the
FCS from an external (C#) app that streams XML messages through a socket. My
appraoch was to simply write an ActionScript movie, which supports XMLSocket
(unlike server-side actionscript). The AS movie runs on the server and connects
to the C# socket (with XMLSocket) and the FCS (with NetConnection). the
XMLSocket.onData (or onXML) then iterates through the attributes of our simple
XML message and creates a generic AS Object, with those properties. It then
passes that object to the FCS using NetConnection.call().

I will post the code, but it is extreamely quick and dirty. I am working on
factoring the code into AS 2.0 classes, but this is not doen yet. I am also
going to use a NetStream to pass the data to the FCS, this way I can store and
play back the stream.

Here's the original working version.

// BusServerInterface


// BusServerSocket
var busServerSocket:XMLSocket = new XMLSocket();
var busStatus = new Object(); // used in onXML to send data to the FCS.


busServerSocket.onConnect = function(success)
{
trace("In busServerSocket.onConnect()");
if (success)
{
trace ("Bus Server Connection Successful");
nc.call("logMsg", null, "Bus Server Connection Successful\n");
}
else
{
trace ("Connection Failed");
nc.call("logMsg", null, "Bus Server Connection Failed\n");
}
}

busServerSocket.onXML = function(XMLMsg)
{

// data looks like this:
// <bustrack busid="123" time="12:34:56" date="12-3456" lat="1234.56"
lon="1234.56" speed="12.3" course="123.4" />

for (var attribute in XMLMsg.firstChild.attributes)
{
// trace(attribute + " = " + XMLMsg.firstChild.attributes[attribute]);
busStatus[attribute] = XMLMsg.firstChild.attributes[attribute];
}

nc.call("updateBusSystemStatus", null, busStatus)
}

//NetConnection
var nc = new NetConnection();
nc.onStatus = function(info)
{
trace("this.isConnected: " + this.isConnected);
trace(" info.level: " + info.level);
trace(" info.code: " + info.code);
trace("info.description: " + info.description);
trace(" info.details: " + info.details);

if (info.application)
{
for (var prop in info.application)
{
trace("info.application." + prop + ": " + info.application[prop]);
}
}
trace("\n");
}
nc.publishStream = function(msg)
{
trace("nc.publishStream("+ msg + ")");
ns.publish("busServerStream", record);
busServerSocket.connect("someServer", somePort);
}

nc.connect("rtmp://someserver/someapp", "busSystemInterface");

var ns = new NetStream(nc);
thatguy2g
6/2/2005 9:55:02 AM
thatguy2g
6/2/2005 10:08:25 AM
Or if anyone knows of any other way to have an application essentially raise
events on a flashcomm server that can then be pushed out to any connected
clients, that would be just as good. Does anyone know of a way to extend
flashcomm using c# or java to do provide such a "listening" functionality?
thatguy2g
6/6/2005 12:00:00 AM
Thanks for the source so far Agorman, I appreciate it.

Still, it seems to me that there MUST be a way to get an open connection
between FlashComm and an XML socket server of sorts as Macromedia's own
product, Breeze must use this to interface with Premiere Global Services audio
conference since I know for a fact that Premiere provides this services through
an SSL-Socket based XML API.

Does anyone from Macromedia read these forums? If so, could you shed some
light on a way (any way) to extend FlashComm in order to allow it to open a
socket connection with a server in order to allow that server to send
unsolicited messages to FlashComm?

If not, can anyone speak to the reliability of a Flash Movie running on the
FlashComm server work-around that Agorman is posting about?
AddThis Social Bookmark Button