Hi,
I’m working on a flash program that consists of a client (written in Flash) and a server (written in Java). Communication between the client and server is done through a xmlsocket. I want to show an error box when the server is unavailable, but I cannot get it to work.
Initially, I created a xmlsocket with a listener attached with code like this:
socket = new XMLSocket();
socket.addEventListener(IOErrorEvent.IO_ERROR, serverDown);
socket.connect(HOST, 31500);
If I tried to connect to my server and it was offline, I would get the error msg as intended. My problem occurred when I took my Flash client and put it on my website. In order for the client (which was now on a different machine) to connect to my server without security issues, I had to set up a policy file. My code was modified to load a policy file before the socket connection was made, as follows:
Security.loadPolicyFile(“xmlsocket://” + HOST + “:31501”);
socket.connect(HOST, 31500);
Everything works great, except that I no longer receive an error msg when the server is offline. If the server is offline and I click the connect button in the client, nothing happens. My hunch is that the code beyond the Security.loadPolicyFile line never executes, and as such, will never reach the socket.connect to fire the error event.
I’m not aware of a way to put a listener on the Security class like I did with the xmlsocket. This is a very tough problem for me to diagnose, as I can’t duplicate it in my testing environment (since both client and server are on the same ip). I was hoping someone who has a deeper understanding of the actionscript language could give me some ideas to try. I’m not sure how to tackle this problem or if I’m missing something really simple. All I need to do is execute the serverDown function should the loadPolicyFile call not locate the server.
Any help appreciated,
thx