Modified: freeswitch/trunk/contrib/seven/fsair/src/fsair.as (14456 => 14457)
--- freeswitch/trunk/contrib/seven/fsair/src/fsair.as 2009-08-01 20:00:18 UTC (rev 14456)
+++ freeswitch/trunk/contrib/seven/fsair/src/fsair.as 2009-08-02 04:22:20 UTC (rev 14457)
@@ -12,11 +12,18 @@
var ring_win:MessageWindow = new MessageWindow();
+ var connect_timer:Timer = new Timer(2000);
+ var re_connect_timer:Timer = new Timer(2000);
+
function initApp():void {
trace(NativeApplication.nativeApplication.runtimeVersion);
ringBox.visible = false;
getSettings();
esl = new ESL(esl_pass.text);
+
+ connect_timer.addEventListener(TimerEvent.TIMER, post_connect);
+ re_connect_timer.addEventListener(TimerEvent.TIMER, re_connect);
+
connect();
}
@@ -40,9 +47,7 @@
esl.addEventCallback("CUSTOM|portaudio::ringing", onRing);
esl.addEventCallback("CHANNEL_HANGUP|-", onHangup);
- var timer:Timer = new Timer(2000);
- timer.addEventListener(TimerEvent.TIMER, post_connect);
- timer.start();
+ connect_timer.start();
msg("timer started");
}
@@ -54,8 +59,31 @@
}
+ function re_connect(event:TimerEvent):void {
+
+ event.target.stop();
+
+ event.target.delay += 2000;
+
+ if (event.target.delay > 120000) {
+ event.target.delay = 2000;
+ }
+
+ msg("Connect faild. will reconnect in " + event.target.delay + " seconds" );
+ connect();
+
+ }
+
function post_connect(event:TimerEvent):void {
+
event.target.stop();
+
+ if (!esl.connected) {
+ event.target.stop();
+ re_connect_timer.start();
+ return;
+ }
+
msg("timer stoped");
initDevList();
// esl.esl_event("ALL");
@@ -91,11 +119,20 @@
}
function ioErrorHandler(event:IOErrorEvent):void {
msg(event.type + ' ' + event.toString());
- setTitle('IOError');
+ setTitle('IOError');
+
+ if (!esl.connected) {
+ connect();
+ }
}
function securityErrorHandler(event:SecurityErrorEvent):void {
msg(event.type + ' ' + event.toString());
- setTitle('SecurityError');
+ setTitle('SecurityError');
+
+ if (!esl.connected) {
+ connect();
+ }
+
}
function onRing(eslev:ESL_event):void {
@@ -303,4 +340,13 @@
esl_port.text = _get_settings("esl_port") || "8021";
esl_pass.text = _get_settings("esl_pass") || "ClueCon";
}
+
+ function runFS():void {
+
+ }
+
+ function shutdownFS():void {
+ esl.api("fsctl shutdown");
+ }
+
\ No newline at end of file
Modified: freeswitch/trunk/contrib/seven/fsair/src/fsair.mxml (14456 => 14457)
--- freeswitch/trunk/contrib/seven/fsair/src/fsair.mxml 2009-08-01 20:00:18 UTC (rev 14456)
+++ freeswitch/trunk/contrib/seven/fsair/src/fsair.mxml 2009-08-02 04:22:20 UTC (rev 14457)
@@ -62,7 +62,8 @@
<mx:Button x="271" y="182" label="Save" click="saveSettings()"/>
<mx:Label x="175" y="80" text="Password" width="58"/>
<mx:TextInput x="175" y="106" width="71" text="ClueCon" id="esl_pass"/>
-
+ <mx:Button x="10" y="182" label="Shutdown FS" click="shutdownFS()"/>
+
</mx:Canvas>
<mx:Panel label="Logs" width="100%" height="100%" layout="absolute">
<mx:TextArea width="326" height="196" id="logBox" x="0" y="2"/>