all groups > macromedia flash flashcom > november 2006 >
You're in the

macromedia flash flashcom

group:

onDisconnect not working as expected on IE7


onDisconnect not working as expected on IE7 Wyldie
11/30/2006 12:00:00 AM
macromedia flash flashcom:
I have an application for a poker game which works perfectly in Firefox 1.5 and
2.0, however in IE7 (not too sure about IE6 thou) there is a serious problem. I
shall explain..

User logs in. Opens a popup of the game which is just a php script which loads
in the SWF. SWF successfully connects the the FCS 1.5 and sits around waiting
for another player... however at any time if the person closes the window or
and any other IE7 windows are open the "onDisconnect" rule on the server side
does not execute, therefore since this game only allows you to play one game at
any one time, if you try to open a window to start a new game it finds an
existing instance of the player.

Only if *all* IE7 windows are closed does the onDisconnect finally recognise
that the person has disconnected.

This is only happening in IE, wherehas FIrefox, Safari and Konq. all work as
expected.

The browser flash plugin is version 9 on all the machines.

Anyone had or experience similar problems with the onDisconnect, and more
importantly.. is there a fix? This is really urgent since this game should have
gone out a while ago, and really just this problem is causing a hold-up.

If it helps, please check out the problem on http://www.pokerwars.com, login,
open a game, close the popup window and re-open a new game... this is driving
me *nuts*

Many thanks
Re: onDisconnect not working as expected on IE7 ManMachine
12/1/2006 12:00:00 AM
Since you are only interested in wether a client is connected when that person
tries to login, all you have to do is set up a method on the client side
NetConnection object which returns true. When a client tries to connect you
check:
(pseudocode)

if(client not connected) {
accept connection
} else {
call the client side method
set a 5 second timeout to accept connection
return null (set connection to pending state)
}

onMethodCallback {
deny connection
cancel timeout
}

/Johan
Re: onDisconnect not working as expected on IE7 JayCharles
12/1/2006 2:07:17 AM
I've found there are a number of situations where the onDisconnect never gets
fired off. In your case, I"m wondering if you're using SWFObject, or more
specifically, and outdated version of SWFObject. I read that previous versions
created such problems with netconnections.

You'll also find that disconnecting the client machine from it's network
(assuming it's on a network and isn't the machine serving the internet
connection) will also cause the ondisconnect not to fire.

What I like to do is set up a little client/server function where each client
calls the server and updates a client variable with the current time, every 5
seconds. Then, every 10 seconds I have a function on the server side run
through the clients and make sure they've updated. If the server side function
encounters a client who hasn't updated in the past 10 seconds, it calls the
onDisconnect for that client.

AddThis Social Bookmark Button