I can connect SFS and disconnect sucessfully but when i disconnect i try to connect again the SFS tell me :
Zone login error; the following error occurred: undefined
[SFS - WARN] You are not connected. Request cannot be sent: [object LoginRequest]
onConnection Success
a part of my code:
public function main() {
initView();
initSmartFox();
}
Start_.addEventListener(MouseEvent.CLICK,Iflogin);
Exit_.addEventListener(MouseEvent.CLICK,gotoExit);
private function initSmartFox():void {
//-----------------------以下是sfs連結------------------------------------//
sfs = new SmartFox();
sfs.addEventListener(SFSEvent.CONNECTION, onConnection);
sfs.addEventListener(SFSEvent.CONNECTION_LOST, onLostConn);
sfs.addEventListener(SFSEvent.LOGIN, onLogin);
sfs.addEventListener(SFSEvent.LOGIN_ERROR, onLoginError);
sfs.connect("127.0.0.1", 9933);
}
private function Iflogin(e:MouseEvent):void {
if (! sfs.isConnected) {
initSmartFox();
login();
} else {
login();
}
}
function gotoExit(Result:Object):void {
sfs.disconnect();
trace("disconnect");
}
disconnect and connect
Re: disconnect and connect
Hi,
From your traces:
You should only send a new LoginRequest on your onConnection event handler, and only if it connected successfully.
From your traces:
It seems that you're sending a LoginRequest before receiving the SFSEvent.CONNECTION event.Zone login error; the following error occurred: undefined
[SFS - WARN] You are not connected. Request cannot be sent: [object LoginRequest]
onConnection Success
You should only send a new LoginRequest on your onConnection event handler, and only if it connected successfully.
Skills: SFS Pro, SFS2X, AS2.0/AS3.0, Java, HTML5/CSS3/JS, C#
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.
Portfolio: https://rjgtav.wordpress.com/
SFS Tutorials: http://sfs-tutor.blogspot.com/ - Discontinued. Some examples may be bugged.