Answered
FMS Shared Objects + NetConnections
I'm trying to make a lobby that initializes other FMS
applications.
Here's the situation:
Media Server Side -onAppStart()-
1) Read an XML file from a remote server
2) Parse out application URLs (i.e. <applicationURL>rtmp://localhost/application_name/room_number</applicationURL>
3) Attempt to connect to the URL on the server side (nc.connect(applicationURL))
4) If this returns NetConnection.Connect.Success, add to the shared object ROOMS_SO.setProperty(room_number, applicationURL) - this is happening in nc.onStatus()
Client Side -ROOMS_SO.onSync()-
1) dataGrid_mc.removeAll();
2) for(i in list) {dataGrid_mc.addItem(list );}
The Problem:
This works fine when users connect and disconnect, but as soon as more than one user is connected, the ROOMS_SO.onSync() method is called over-and-over-and-over... which means my dataGrid_mc object is being refreshed infinitely. The only way I can stop it is to disconnect all users but one.
Any thoughts?
I have a users_so object updating a list (basically a "who's here" list) without any problems whatsoever using the same method (minus the XML / net connection business)
Code breakdown (simplified for clarity):
--= Server Side =-- (in onAppStart())
applicationURLs_so = SharedObject.get("applicationURLs_so", false);
xmlObj.onLoad = function() {
var nodes = this.firstChild.childNodes;
var connectionURL = "";
var uniqueID = "";
for(i = 0; i < nodes.length; i++) {
connectionURL = nodes.childNodes[0].nodeValue;
uniqueID = nodes .childNodes[1].nodeValue;
initConnection(connectionURL, uniqueID);
}
}
initConnection = function(connectionURL, uniqueID) {
var nc = new NetConnection();
nc.connect(connectionURL);
nc.onStatus = function(info) {
if(info.code == "NetConnection.Connect.Success") {applicationURLs_so.setProperty(uniqueID, connectionURL);}
try {this.close();} catch(exception) {}
}
}
--= Client Side =--
applicationURLs_so.onSync = function(info)
{
dataGrid_mc.removeAll();
for(i in this.data) {dataGrid_mc.addItem(this.data);}
}
Here's the situation:
Media Server Side -onAppStart()-
1) Read an XML file from a remote server
2) Parse out application URLs (i.e. <applicationURL>rtmp://localhost/application_name/room_number</applicationURL>
3) Attempt to connect to the URL on the server side (nc.connect(applicationURL))
4) If this returns NetConnection.Connect.Success, add to the shared object ROOMS_SO.setProperty(room_number, applicationURL) - this is happening in nc.onStatus()
Client Side -ROOMS_SO.onSync()-
1) dataGrid_mc.removeAll();
2) for(i in list) {dataGrid_mc.addItem(list );}
The Problem:
This works fine when users connect and disconnect, but as soon as more than one user is connected, the ROOMS_SO.onSync() method is called over-and-over-and-over... which means my dataGrid_mc object is being refreshed infinitely. The only way I can stop it is to disconnect all users but one.
Any thoughts?
I have a users_so object updating a list (basically a "who's here" list) without any problems whatsoever using the same method (minus the XML / net connection business)
Code breakdown (simplified for clarity):
--= Server Side =-- (in onAppStart())
applicationURLs_so = SharedObject.get("applicationURLs_so", false);
xmlObj.onLoad = function() {
var nodes = this.firstChild.childNodes;
var connectionURL = "";
var uniqueID = "";
for(i = 0; i < nodes.length; i++) {
connectionURL = nodes.childNodes[0].nodeValue;
uniqueID = nodes .childNodes[1].nodeValue;
initConnection(connectionURL, uniqueID);
}
}
initConnection = function(connectionURL, uniqueID) {
var nc = new NetConnection();
nc.connect(connectionURL);
nc.onStatus = function(info) {
if(info.code == "NetConnection.Connect.Success") {applicationURLs_so.setProperty(uniqueID, connectionURL);}
try {this.close();} catch(exception) {}
}
}
--= Client Side =--
applicationURLs_so.onSync = function(info)
{
dataGrid_mc.removeAll();
for(i in this.data) {dataGrid_mc.addItem(this.data);}
}
