I have multiplayer flash game (AS3) and I would like to prevent multiboxing, e.g. prevent user running two (or more) instances of my game at one computer. Is there simple and reliable way how to do that? I don't want to filter them based on IP address.
I tried to use LocalConnection, but it was unreliable. It worked most of the time but for some reason it failed sometimes.
Then I tried to use SharedObject to write random value to it and than check for change in periodic interval. Idea is that when second instance starts, it will overwrite previous value and check in first instance will fail.
public function MultiboxPreventer(callback:Function)
{
uniqueKey = Math.random() * uint.MAX_VALUE;
so = SharedObject.getLocal("prefs");
so.data.multiboxKey = uniqueKey;
so.flush();
trace("MB init: " + so.data.multiboxKey);
so = null;
this.callback = callback;
var t:Timer = new Timer(10000, 0);
t.addEventListener(TimerEvent.TIMER, checkKey);
t.start();
}
private function checkKey(event:TimerEvent):void {
so = SharedObject.getLocal("prefs");
if(so.data.multiboxKey != uniqueKey) {
callback();
}
trace("MB check: " + so.data.multiboxKey);
}
but when I test this it behaves as if each instance had its own SharedObject so they never rewrite each other's value.
What is best way to accomplish this?