Psst! Did you know DevelopmentNow is a mobile web site design agency?

Contact us for help mobilizing your site, or to sign up for our beta Mobile Web SDK!
all groups > macromedia flash flashcom > january 2006 >

macromedia flash flashcom : FCS connect


ActionScripter1
1/28/2006 3:16:43 PM
Hi Guys,

I have a little issue with my connection.
i am running my CCTV through my FlashComm Server and I have to start my
broadcast manually.
if the server goes down then i have to go back to the location where my CCTV
is and re-start my broadcast it can be quite a pain.

What I would like to know is how to check for the connection to the server and
if it is down auto reconnect.

Any ideas welcome.

Thanks in advance.
JayCharles
1/28/2006 10:12:04 PM
You would handle that in the client side onStatus event for the netconnection

nc.onstatus=function(info){
if (info.code == "NetConnection.Connect.Closed"){
//code to reconnect here
}
if (info.code == "NetConnection.Connect.Failed"){
//code to reconnect here
}
if (info.code == "NetConnection.Connect.Rejected"){
//code to reconnect here
}
}

Keep in mind that this will cause the player to continuously attempt
connections when there isn't one, so you might want to set up some other
conditions to limit the number of attempts.

See the docs for the netconnection onstatus event for more info.


ActionScripter1
1/31/2006 1:12:14 AM
Thanks for that, it will be a great help.

Now that I have added this code i seem to be having a little problem
connecting.

here is what I have upto now

mycam = Camera.get();
mycam.setQuality(25600, 0);
mymic = Microphone.get();
mymic.setRate(11);
ns.attachVideo(mycam);
ns.attachAudio(mymic);
myvid.attachVideo(mycam);
nc = new NetConnection();
nc.onStatus = function(info) {
if (info.code == "NetConnection.Connect.Success") {
createNetStream(this);
}
}
nc.connect(_root.rtmp_txt.text);
ns.publish(_root.streamname_txt.text, "live");
createNetStream = function(nc){
ns = new NetStream(nc);
ns.onStatus = function(info) {
if (info.code == "NetConnection.Connect.Closed"){
nc.connect(_root.rtmp_txt.text);
ns.publish(_root.streamname_txt.text, "live");
}
if (info.code == "NetConnection.Connect.Failed"){
nc.connect(_root.rtmp_txt.text);
ns.publish(_root.streamname_txt.text, "live");
}
if (info.code == "NetConnection.Connect.Rejected"){
nc.connect(_root.rtmp_txt.text);
ns.publish(_root.streamname_txt.text, "live");
}
}
mycam = Camera.get();
mycam.setQuality(25600, 0);
mymic = Microphone.get();
mymic.setRate(11);
ns.attachVideo(mycam);
ns.attachAudio(mymic);
myvid.attachVideo(mycam);
}

I am not too good at all this so if you can see where I am going wrong I would
appreciate any more help.

thanks in advance.
AddThis Social Bookmark Button