SmartFoxServer Connection XML config file

stop();

import it.gotoandplay.smartfoxserver.*;
import it.gotoandplay.smartfoxserver.data.*;

var sfs:SmartFoxClient = new SmartFoxClient();
//load config file
sfs.addEventListener(SFSEvent.onConfigLoadSuccess, onConfigLoadSuccessHandler);
sfs.addEventListener(SFSEvent.onConfigLoadFailure, onConfigLoadFailureHandler);
sfs.addEventListener(SFSEvent.onRoomListUpdate,onRoomListUpdate);
sfs.loadConfig("config.xml", false);

msg.text="";

function onConfigLoadSuccessHandler(evt:SFSEvent):void
{
msg.text = "Config file loaded, now connected...";
sfs.connect(sfs.ipAddress, sfs.port);
gotoAndStop("cRoom", "Scene 1");

}

function onConfigLoadFailureHandler(evt:SFSEvent):void
{
msg.text = "Failed loading config file: " + evt.params.message;
}

function onRoomListUpdate(e:SFSEvent):void
{
sfs.autoJoin();

}

0 comments:

Post a Comment