disconnect and connect

Post here your questions about the Flash / Flex / Air API for SFS2X

Moderators: Lapo, Bax

Post Reply
m87dd05
Posts: 4
Joined: 12 Aug 2013, 10:06

disconnect and connect

Post by m87dd05 »

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");
}
User avatar
rjgtav
Posts: 2813
Joined: 19 Apr 2009, 11:31
Location: Lisbon, Portugal

Re: disconnect and connect

Post by rjgtav »

Hi,

From your traces:
Zone login error; the following error occurred: undefined
[SFS - WARN] You are not connected. Request cannot be sent: [object LoginRequest]
onConnection Success
It seems that you're sending a LoginRequest before receiving the SFSEvent.CONNECTION event.
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.
Post Reply