Reconnect to server

Post here your questions about the OpenSpace 2.x or notify bugs and suggestions.

Moderators: Lapo, Bax

Darkwing Duck
Posts: 20
Joined: 21 Dec 2010, 13:17

Reconnect to server

Postby Darkwing Duck » 11 Apr 2011, 09:21

Hi!
How i can reconnect to the server?
i try that:

[code]_sfs.disconnect();
_sfs.connect(IP, GameParametersProxy.instance.port);[/code]
Last edited by Darkwing Duck on 05 May 2011, 07:53, edited 1 time in total.
User avatar
Lapo
Site Admin
Posts: 23025
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 12 Apr 2011, 07:04

Why would you do that?
I mean why disconnecting like that and then immediately reconnecting?
It looks like you just need a logout which is a much safer operation, please take a look at the documentation.
Lapo
--
gotoAndPlay()
...addicted to flash games
Darkwing Duck
Posts: 20
Joined: 21 Dec 2010, 13:17

Postby Darkwing Duck » 12 Apr 2011, 12:02

I want reconnect client to another ip..
User avatar
Lapo
Site Admin
Posts: 23025
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 12 Apr 2011, 12:45

Then you need to give it a pause. The disconnection doesn't happen instantaneously. Your reconnection attempt is too fast.
You should at least wait for the disconnection event.

In alternative you can call disconnect to close the previous connection and create a new SmartFox object that you connect to the new IP.
Lapo

--

gotoAndPlay()

...addicted to flash games
Darkwing Duck
Posts: 20
Joined: 21 Dec 2010, 13:17

Postby Darkwing Duck » 12 Apr 2011, 16:25

Thanks.. but the exception thrown when I call the _sfs.disconnect(); method
User avatar
Lapo
Site Admin
Posts: 23025
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 12 Apr 2011, 16:35

No I don't think so.
Take a look a the stack trace:

at flash.net::Socket/writeBytes()
at it.gotoandplay.smartfoxserver::SmartFoxClient/writeToSocket()
at it.gotoandplay.smartfoxserver::SmartFoxClient/send()
at it.gotoandplay.smartfoxserver::SmartFoxClient/setUserVariables()
at com.smartfoxserver.openspace.engine.control::OpenSpaceController/

The cause of the problem is a SetUserVariables Request. Maybe it happens concurrently with the disconnection because of an OpenSpace event.
You should probably make a more graceful disconnection, where you first turn off OpenSpace and then disconnect the socket.
Lapo

--

gotoAndPlay()

...addicted to flash games
Darkwing Duck
Posts: 20
Joined: 21 Dec 2010, 13:17

Postby Darkwing Duck » 12 Apr 2011, 16:46

well..
1. how i can turn off the openspace?

2. when this exception is not appear, i see this:


[quote]****************************************************************
Internal error:
The room list is empty!
The client API cannot function properly until the room list is populated.
Please consult the documentation for more infos.
****************************************************************
[Sending]: <msg t='sys'><body action='verChk' r='0'><ver v='157' /></body></msg>

[ RECEIVED ]: <cross-domain-policy><allow-access-from domain='*' to-ports='9339' /></cross-domain-policy>, (len: 91)
[ RECEIVED ]: <msg t='sys'><body action='apiOK' r='0'></body></msg>, (len: 53)
[/quote]
User avatar
Bax
Site Admin
Posts: 4612
Joined: 29 Mar 2005, 09:50
Location: Italy
Contact:

Postby Bax » 15 Apr 2011, 10:31

1) To "turn off" OpenSpace, call the IOpenSpace.unloadMap method.
2) That error is traced whenever you try to call some SFS methods before the roomlist was received.
Paolo Bax
The SmartFoxServer Team
dean graziosi
Posts: 5
Joined: 18 Apr 2011, 07:14

Postby dean graziosi » 18 Apr 2011, 07:30

Thanks for sharing this wonderful experience about server disconnection. I got the solution here. We just believe to do restart when error occur. We did it thrice in a day, but finally get solution here.

Return to “OpenSpace v2 discussions and help”

Who is online

Users browsing this forum: No registered users and 12 guests