Update: Found the fix to the problem and posted it on the 3rd message in this thread. A new issue/question sprouts though, relating to BlueBox.
Hey all,
I've been getting the hang of SFS pretty quickly. An old problem comes back to haunt me though... for those who recall my earlier post, failed connections weren't calling the SFC.onConnection handler, making me hard to debug and isolate the real problem I had. It didn't bother me as much before because I was just concerned with building a working app, but now that I have something substantial I would like to handle a failed connection error gracefully with a UI notice. I'm currently using the AS3 libraries that come with SFS PRO. This is the isolated code I'm testing this with:
Code: Select all
package{
import it.gotoandplay.smartfoxserver.*;
import flash.display.*;
public class simple extends MovieClip{
var sfs:SmartFoxClient;
public function simple(){
sfs = new SmartFoxClient(true);
sfs.addEventListener(SFSEvent.onConnection,connectionHandler);
sfs.connect(<MY IP>,9339);
}
private function connectionHandler(e:SFSEvent):void{
trace('conn');
}
}
}
Naturally, replace <MY IP> with what the SFS server IP. In this scenario, the console window should still print 'conn' regardless of whether the connection was successful or not, since the connectionHandler is invoked in both cases, just that the e.params variable will hold different things based on the outcome. Running this app with SFS running connects and prints 'conn' as expected, but running this app with SFS not running does not print 'conn', when it is expected to do so.
Here's a weird observation: when I have <MY IP> set to '127.0.0.1', it does go through the whole thing and performs the output as expected regardless of whether SFS is running or not (this only happens when I'm running the app either right from Flash or from my local machine). But when I set <MY IP> to my machine's true IP address, it seems to hang and refuse to throw any errors. In the latter case, is SFS trying to connect, and refusing to time out and throw an error?
I've been tearing my hair out on this problem since last night, so I'd dearly appreciate any help you guys can offer!
UPDATE: when running it within Adobe Flash CS3 using my machine's full IP address to connect, it eventually did as it was supposed to, but took a looooong time (around 1 minute for the first debug message to appear). When i ran it on a browser however, it was just stuck, with my browser's status bar saying "Connecting to <IP address I specified>..." This one didn't budge. Is there anything I can do to make it time out faster? Note that editing any of the SFS config files won't help since I'm trying to simulate a situation when SFS is completely offline.
-Jay