Page 1 of 1
Reconnect to server
Posted: 11 Apr 2011, 09:21
by Darkwing Duck
Hi!
How i can reconnect to the server?
i try that:
[code]_sfs.disconnect();
_sfs.connect(IP, GameParametersProxy.instance.port);[/code]
Posted: 12 Apr 2011, 07:04
by Lapo
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.
Posted: 12 Apr 2011, 12:02
by Darkwing Duck
I want reconnect client to another ip..
Posted: 12 Apr 2011, 12:45
by Lapo
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.
Posted: 12 Apr 2011, 16:25
by Darkwing Duck
Thanks.. but the exception thrown when I call the _sfs.disconnect(); method
Posted: 12 Apr 2011, 16:35
by Lapo
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.
Posted: 12 Apr 2011, 16:46
by Darkwing Duck
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]
Posted: 15 Apr 2011, 10:31
by Bax
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.
Posted: 18 Apr 2011, 07:30
by dean graziosi
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.