A connection attempt is already running

Post here your questions about the Java client / Android API for SFS2X

Moderators: Lapo, Bax

QiXi
Posts: 7
Joined: 06 Feb 2013, 16:46
Location: Russia
Contact:

A connection attempt is already running

Postby QiXi » 17 Mar 2015, 10:34

My application does not connect a second time
always writes
A connection attempt is already running

cource SmartFox.class

Code: Select all

    public void handleHandShake(BaseEvent evt) {
        SFSObject obj = (SFSObject)evt.getArguments().get("message");
        if(!obj.containsKey("ec")) {
            ...
            if(this.bitSwarm.isReconnecting()) {
                this.bitSwarm.setReconnecting(false);
                this.dispatchEvent(new SFSEvent("connectionResume"));     //!!!!! may be this.isConnecting = false; ???
            } else {
                this.isConnecting = false;
                HashMap errorCode = new HashMap();
                errorCode.put("success", Boolean.valueOf(true));
                this.dispatchEvent(new SFSEvent("connection", errorCode));
            }
        } else {
            ...
        }

    }
QiXi
Posts: 7
Joined: 06 Feb 2013, 16:46
Location: Russia
Contact:

Re: A connection attempt is already running

Postby QiXi » 17 Mar 2015, 21:09

log:
>>connect_1
CONNECTION_SUCCESS
HANDSHAKE
LOGIN
...
//off Wi-Fi
...
CONNECTION_RETRY
TCPSocketLayer: Socket error
BitSwarmClient﹕ Reconnection attempt:2 - time left:7
...
CONNECTION_LOST

//on Wi-Fi

>>connect_2
CONNECTION_RESUME
HANDSHAKE

//off Wi-Fi

TCPSocketLayer: Socket error
BitSwarmClient﹕ Reconnection attempt:2 - time left:7
CONNECTION_LOST

//on Wi-Fi

>>connect_3
SmartFox﹕ A connection attempt is already running
>>connect_4
SmartFox﹕ A connection attempt is already running
etc.
etc.


may be missing SmartFox.class

Code: Select all

private void reset() {
 this.isConnecting = false; ???
}
User avatar
Lapo
Site Admin
Posts: 20219
Joined: 21 Mar 2005, 09:50
Location: Italy

Re: A connection attempt is already running

Postby Lapo » 18 Mar 2015, 12:42

You cannot connect twice.
If you have disconnected, you should unregister the previous listeners, dereference the previous SmartFox instance and create a new one.

In essence for every new connection you need a new SmartFox object.

Hope it helps
Lapo
--
gotoAndPlay()
...addicted to flash games

Return to “SFS2X Java / Android API”

Who is online

Users browsing this forum: No registered users and 3 guests