mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-19 01:27:51 -05:00
Brought up to date with the private repository (feea4c7)
This commit is contained in:
1 parent
1aa738d692
commit
1b1df1ae48
7925 files changed
+2617237
-20
No files matched your search
@@ -0,0 +1,95 @@
|
||||
package it.gotoandplay.smartfoxserver
|
||||
{
|
||||
import flash.events.Event;
|
||||
|
||||
public class SFSEvent extends Event
|
||||
{
|
||||
|
||||
public static const onAdminMessage:String = "onAdminMessage";
|
||||
|
||||
public static const onBuddyList:String = "onBuddyList";
|
||||
|
||||
public static const onBuddyListError:String = "onBuddyListError";
|
||||
|
||||
public static const onBuddyListUpdate:String = "onBuddyListUpdate";
|
||||
|
||||
public static const onBuddyPermissionRequest:String = "onBuddyPermissionRequest";
|
||||
|
||||
public static const onBuddyRoom:String = "onBuddyRoom";
|
||||
|
||||
public static const onConfigLoadFailure:String = "onConfigLoadFailure";
|
||||
|
||||
public static const onConfigLoadSuccess:String = "onConfigLoadSuccess";
|
||||
|
||||
public static const onConnection:String = "onConnection";
|
||||
|
||||
public static const onConnectionLost:String = "onConnectionLost";
|
||||
|
||||
public static const onCreateRoomError:String = "onCreateRoomError";
|
||||
|
||||
public static const onDebugMessage:String = "onDebugMessage";
|
||||
|
||||
public static const onExtensionResponse:String = "onExtensionResponse";
|
||||
|
||||
public static const onJoinRoom:String = "onJoinRoom";
|
||||
|
||||
public static const onJoinRoomError:String = "onJoinRoomError";
|
||||
|
||||
public static const onLogin:String = "onLogin";
|
||||
|
||||
public static const onLogout:String = "onLogout";
|
||||
|
||||
public static const onModeratorMessage:String = "onModMessage";
|
||||
|
||||
public static const onObjectReceived:String = "onObjectReceived";
|
||||
|
||||
public static const onPrivateMessage:String = "onPrivateMessage";
|
||||
|
||||
public static const onPublicMessage:String = "onPublicMessage";
|
||||
|
||||
public static const onRandomKey:String = "onRandomKey";
|
||||
|
||||
public static const onRoomAdded:String = "onRoomAdded";
|
||||
|
||||
public static const onRoomDeleted:String = "onRoomDeleted";
|
||||
|
||||
public static const onRoomLeft:String = "onRoomLeft";
|
||||
|
||||
public static const onRoomListUpdate:String = "onRoomListUpdate";
|
||||
|
||||
public static const onRoomVariablesUpdate:String = "onRoomVariablesUpdate";
|
||||
|
||||
public static const onRoundTripResponse:String = "onRoundTripResponse";
|
||||
|
||||
public static const onSpectatorSwitched:String = "onSpectatorSwitched";
|
||||
|
||||
public static const onPlayerSwitched:String = "onPlayerSwitched";
|
||||
|
||||
public static const onUserCountChange:String = "onUserCountChange";
|
||||
|
||||
public static const onUserEnterRoom:String = "onUserEnterRoom";
|
||||
|
||||
public static const onUserLeaveRoom:String = "onUserLeaveRoom";
|
||||
|
||||
public static const onUserVariablesUpdate:String = "onUserVariablesUpdate";
|
||||
|
||||
public var params:Object;
|
||||
|
||||
public function SFSEvent(param1:String, param2:Object)
|
||||
{
|
||||
super(param1);
|
||||
this.params = param2;
|
||||
}
|
||||
|
||||
override public function clone() : Event
|
||||
{
|
||||
return new SFSEvent(this.type,this.params);
|
||||
}
|
||||
|
||||
override public function toString() : String
|
||||
{
|
||||
return formatToString("SFSEvent","type","bubbles","cancelable","eventPhase","params");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,212 @@
|
||||
package it.gotoandplay.smartfoxserver.data
|
||||
{
|
||||
public class Room
|
||||
{
|
||||
|
||||
private var id:int;
|
||||
|
||||
private var name:String;
|
||||
|
||||
private var maxUsers:int;
|
||||
|
||||
private var maxSpectators:int;
|
||||
|
||||
private var temp:Boolean;
|
||||
|
||||
private var game:Boolean;
|
||||
|
||||
private var priv:Boolean;
|
||||
|
||||
private var limbo:Boolean;
|
||||
|
||||
private var userCount:int;
|
||||
|
||||
private var specCount:int;
|
||||
|
||||
private var myPlayerIndex:int;
|
||||
|
||||
private var userList:Array;
|
||||
|
||||
private var variables:Array;
|
||||
|
||||
public function Room(param1:int, param2:String, param3:int, param4:int, param5:Boolean, param6:Boolean, param7:Boolean, param8:Boolean, param9:int = 0, param10:int = 0)
|
||||
{
|
||||
super();
|
||||
this.id = param1;
|
||||
this.name = param2;
|
||||
this.maxSpectators = param4;
|
||||
this.maxUsers = param3;
|
||||
this.temp = param5;
|
||||
this.game = param6;
|
||||
this.priv = param7;
|
||||
this.limbo = param8;
|
||||
this.userCount = param9;
|
||||
this.specCount = param10;
|
||||
this.userList = [];
|
||||
this.variables = [];
|
||||
}
|
||||
|
||||
public function addUser(param1:User, param2:int) : void
|
||||
{
|
||||
userList[param2] = param1;
|
||||
if(this.game && param1.isSpectator())
|
||||
{
|
||||
specCount = specCount + 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
userCount = userCount + 1;
|
||||
}
|
||||
}
|
||||
|
||||
public function removeUser(param1:int) : void
|
||||
{
|
||||
var _loc2_:User = userList[param1];
|
||||
if(this.game && _loc2_.isSpectator())
|
||||
{
|
||||
specCount = specCount - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
userCount = userCount - 1;
|
||||
}
|
||||
delete userList[param1];
|
||||
}
|
||||
|
||||
public function getUserList() : Array
|
||||
{
|
||||
return this.userList;
|
||||
}
|
||||
|
||||
public function getUser(param1:*) : User
|
||||
{
|
||||
var _loc2_:User = null;
|
||||
var _loc4_:User = null;
|
||||
if(typeof param1 == "number")
|
||||
{
|
||||
_loc4_ = userList[param1];
|
||||
}
|
||||
else if(typeof param1 == "string")
|
||||
{
|
||||
for(var _loc3_:String in userList)
|
||||
{
|
||||
_loc2_ = this.userList[_loc3_];
|
||||
if(_loc2_.getName() == param1)
|
||||
{
|
||||
_loc4_ = _loc2_;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return _loc4_;
|
||||
}
|
||||
|
||||
public function clearUserList() : void
|
||||
{
|
||||
this.userList = [];
|
||||
this.userCount = 0;
|
||||
this.specCount = 0;
|
||||
}
|
||||
|
||||
public function getVariable(param1:String) : *
|
||||
{
|
||||
return variables[param1];
|
||||
}
|
||||
|
||||
public function getVariables() : Array
|
||||
{
|
||||
return variables;
|
||||
}
|
||||
|
||||
public function setVariables(param1:Array) : void
|
||||
{
|
||||
this.variables = param1;
|
||||
}
|
||||
|
||||
public function clearVariables() : void
|
||||
{
|
||||
this.variables = [];
|
||||
}
|
||||
|
||||
public function getName() : String
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public function getId() : int
|
||||
{
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public function isTemp() : Boolean
|
||||
{
|
||||
return this.temp;
|
||||
}
|
||||
|
||||
public function isGame() : Boolean
|
||||
{
|
||||
return this.game;
|
||||
}
|
||||
|
||||
public function isPrivate() : Boolean
|
||||
{
|
||||
return this.priv;
|
||||
}
|
||||
|
||||
public function getUserCount() : int
|
||||
{
|
||||
return this.userCount;
|
||||
}
|
||||
|
||||
public function getSpectatorCount() : int
|
||||
{
|
||||
return this.specCount;
|
||||
}
|
||||
|
||||
public function getMaxUsers() : int
|
||||
{
|
||||
return this.maxUsers;
|
||||
}
|
||||
|
||||
public function getMaxSpectators() : int
|
||||
{
|
||||
return this.maxSpectators;
|
||||
}
|
||||
|
||||
public function setMyPlayerIndex(param1:int) : void
|
||||
{
|
||||
this.myPlayerIndex = param1;
|
||||
}
|
||||
|
||||
public function getMyPlayerIndex() : int
|
||||
{
|
||||
return this.myPlayerIndex;
|
||||
}
|
||||
|
||||
public function setIsLimbo(param1:Boolean) : void
|
||||
{
|
||||
this.limbo = param1;
|
||||
}
|
||||
|
||||
public function isLimbo() : Boolean
|
||||
{
|
||||
return this.limbo;
|
||||
}
|
||||
|
||||
public function setUserCount(param1:int) : void
|
||||
{
|
||||
this.userCount = param1;
|
||||
}
|
||||
|
||||
public function setSpectatorCount(param1:int) : void
|
||||
{
|
||||
this.specCount = param1;
|
||||
}
|
||||
|
||||
public function setUserList(param1:Array) : void
|
||||
{
|
||||
this.userList = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
package it.gotoandplay.smartfoxserver.data
|
||||
{
|
||||
public class User
|
||||
{
|
||||
|
||||
private var id:int;
|
||||
|
||||
private var name:String;
|
||||
|
||||
private var variables:Array;
|
||||
|
||||
private var isSpec:Boolean;
|
||||
|
||||
private var isMod:Boolean;
|
||||
|
||||
private var pId:int;
|
||||
|
||||
public function User(param1:int, param2:String)
|
||||
{
|
||||
super();
|
||||
this.id = param1;
|
||||
this.name = param2;
|
||||
this.variables = [];
|
||||
this.isSpec = false;
|
||||
this.isMod = false;
|
||||
}
|
||||
|
||||
public function getId() : int
|
||||
{
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public function getName() : String
|
||||
{
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public function getVariable(param1:String) : *
|
||||
{
|
||||
return this.variables[param1];
|
||||
}
|
||||
|
||||
public function getVariables() : Array
|
||||
{
|
||||
return this.variables;
|
||||
}
|
||||
|
||||
public function setVariables(param1:Object) : void
|
||||
{
|
||||
var _loc2_:* = undefined;
|
||||
for(var _loc3_:String in param1)
|
||||
{
|
||||
_loc2_ = param1[_loc3_];
|
||||
if(_loc2_ != null)
|
||||
{
|
||||
this.variables[_loc3_] = _loc2_;
|
||||
}
|
||||
else
|
||||
{
|
||||
delete this.variables[_loc3_];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function clearVariables() : void
|
||||
{
|
||||
this.variables = [];
|
||||
}
|
||||
|
||||
public function setIsSpectator(param1:Boolean) : void
|
||||
{
|
||||
this.isSpec = param1;
|
||||
}
|
||||
|
||||
public function isSpectator() : Boolean
|
||||
{
|
||||
return this.isSpec;
|
||||
}
|
||||
|
||||
public function setModerator(param1:Boolean) : void
|
||||
{
|
||||
this.isMod = param1;
|
||||
}
|
||||
|
||||
public function isModerator() : Boolean
|
||||
{
|
||||
return this.isMod;
|
||||
}
|
||||
|
||||
public function getPlayerId() : int
|
||||
{
|
||||
return this.pId;
|
||||
}
|
||||
|
||||
public function setPlayerId(param1:int) : void
|
||||
{
|
||||
this.pId = param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
package it.gotoandplay.smartfoxserver.handlers
|
||||
{
|
||||
import it.gotoandplay.smartfoxserver.SFSEvent;
|
||||
import it.gotoandplay.smartfoxserver.SmartFoxClient;
|
||||
import it.gotoandplay.smartfoxserver.util.ObjectSerializer;
|
||||
|
||||
public class ExtHandler implements IMessageHandler
|
||||
{
|
||||
|
||||
private var sfs:SmartFoxClient;
|
||||
|
||||
public function ExtHandler(param1:SmartFoxClient)
|
||||
{
|
||||
super();
|
||||
this.sfs = param1;
|
||||
}
|
||||
|
||||
public function handleMessage(param1:Object, param2:String) : void
|
||||
{
|
||||
var _loc6_:Object = null;
|
||||
var _loc3_:SFSEvent = null;
|
||||
var _loc9_:XML = null;
|
||||
var _loc4_:String = null;
|
||||
var _loc8_:int = 0;
|
||||
var _loc7_:String = null;
|
||||
var _loc5_:Object = null;
|
||||
if(param2 == "xml")
|
||||
{
|
||||
_loc9_ = param1 as XML;
|
||||
_loc4_ = _loc9_.body.@action;
|
||||
_loc8_ = int(_loc9_.body.@id);
|
||||
if(_loc4_ == "xtRes")
|
||||
{
|
||||
_loc7_ = _loc9_.body.toString();
|
||||
_loc5_ = ObjectSerializer.getInstance().deserialize(_loc7_);
|
||||
_loc6_ = {};
|
||||
_loc6_.dataObj = _loc5_;
|
||||
_loc6_.type = param2;
|
||||
_loc3_ = new SFSEvent("onExtensionResponse",_loc6_);
|
||||
sfs.dispatchEvent(_loc3_);
|
||||
}
|
||||
}
|
||||
else if(param2 == "json")
|
||||
{
|
||||
_loc6_ = {};
|
||||
_loc6_.dataObj = param1.o;
|
||||
_loc6_.type = param2;
|
||||
_loc3_ = new SFSEvent("onExtensionResponse",_loc6_);
|
||||
sfs.dispatchEvent(_loc3_);
|
||||
}
|
||||
else if(param2 == "str")
|
||||
{
|
||||
_loc6_ = {};
|
||||
_loc6_.dataObj = param1;
|
||||
_loc6_.type = param2;
|
||||
_loc3_ = new SFSEvent("onExtensionResponse",_loc6_);
|
||||
sfs.dispatchEvent(_loc3_);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
package it.gotoandplay.smartfoxserver.handlers
|
||||
{
|
||||
public interface IMessageHandler
|
||||
{
|
||||
|
||||
function handleMessage(param1:Object, param2:String) : void;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,776 @@
|
||||
package it.gotoandplay.smartfoxserver.handlers
|
||||
{
|
||||
import flash.utils.getTimer;
|
||||
import it.gotoandplay.smartfoxserver.SFSEvent;
|
||||
import it.gotoandplay.smartfoxserver.SmartFoxClient;
|
||||
import it.gotoandplay.smartfoxserver.data.Room;
|
||||
import it.gotoandplay.smartfoxserver.data.User;
|
||||
import it.gotoandplay.smartfoxserver.util.Entities;
|
||||
import it.gotoandplay.smartfoxserver.util.FailCode;
|
||||
import it.gotoandplay.smartfoxserver.util.ObjectSerializer;
|
||||
|
||||
public class SysHandler implements IMessageHandler
|
||||
{
|
||||
|
||||
private var sfs:SmartFoxClient;
|
||||
|
||||
private var handlersTable:Array;
|
||||
|
||||
public function SysHandler(param1:SmartFoxClient)
|
||||
{
|
||||
super();
|
||||
this.sfs = param1;
|
||||
handlersTable = [];
|
||||
handlersTable["apiOK"] = this.handleApiOK;
|
||||
handlersTable["apiKO"] = this.handleApiKO;
|
||||
handlersTable["logOK"] = this.handleLoginOk;
|
||||
handlersTable["logKO"] = this.handleLoginKo;
|
||||
handlersTable["logout"] = this.handleLogout;
|
||||
handlersTable["rmList"] = this.handleRoomList;
|
||||
handlersTable["uCount"] = this.handleUserCountChange;
|
||||
handlersTable["joinOK"] = this.handleJoinOk;
|
||||
handlersTable["joinKO"] = this.handleJoinKo;
|
||||
handlersTable["uER"] = this.handleUserEnterRoom;
|
||||
handlersTable["userGone"] = this.handleUserLeaveRoom;
|
||||
handlersTable["pubMsg"] = this.handlePublicMessage;
|
||||
handlersTable["prvMsg"] = this.handlePrivateMessage;
|
||||
handlersTable["dmnMsg"] = this.handleAdminMessage;
|
||||
handlersTable["modMsg"] = this.handleModMessage;
|
||||
handlersTable["dataObj"] = this.handleASObject;
|
||||
handlersTable["rVarsUpdate"] = this.handleRoomVarsUpdate;
|
||||
handlersTable["roomAdd"] = this.handleRoomAdded;
|
||||
handlersTable["roomDel"] = this.handleRoomDeleted;
|
||||
handlersTable["rndK"] = this.handleRandomKey;
|
||||
handlersTable["roundTripRes"] = this.handleRoundTripBench;
|
||||
handlersTable["uVarsUpdate"] = this.handleUserVarsUpdate;
|
||||
handlersTable["createRmKO"] = this.handleCreateRoomError;
|
||||
handlersTable["bList"] = this.handleBuddyList;
|
||||
handlersTable["bUpd"] = this.handleBuddyListUpdate;
|
||||
handlersTable["bAdd"] = this.handleBuddyAdded;
|
||||
handlersTable["roomB"] = this.handleBuddyRoom;
|
||||
handlersTable["leaveRoom"] = this.handleLeaveRoom;
|
||||
handlersTable["swSpec"] = this.handleSpectatorSwitched;
|
||||
handlersTable["bPrm"] = this.handleAddBuddyPermission;
|
||||
handlersTable["remB"] = this.handleRemoveBuddy;
|
||||
handlersTable["swPl"] = this.handlePlayerSwitched;
|
||||
}
|
||||
|
||||
public function handleMessage(param1:Object, param2:String) : void
|
||||
{
|
||||
var _loc5_:XML = param1 as XML;
|
||||
var _loc4_:String = _loc5_.body.@action;
|
||||
var _loc3_:Function = handlersTable[_loc4_];
|
||||
if(_loc3_ != null)
|
||||
{
|
||||
_loc3_.apply(this,[param1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
trace("Unknown sys command: " + _loc4_);
|
||||
}
|
||||
}
|
||||
|
||||
public function handleApiOK(param1:Object) : void
|
||||
{
|
||||
sfs.isConnected = true;
|
||||
var _loc2_:SFSEvent = new SFSEvent("onConnection",{"success":true});
|
||||
sfs.dispatchEvent(_loc2_);
|
||||
}
|
||||
|
||||
public function handleApiKO(param1:Object) : void
|
||||
{
|
||||
var _loc3_:Object = {};
|
||||
_loc3_.success = false;
|
||||
_loc3_.error = "API are obsolete, please upgrade";
|
||||
_loc3_.failCode = FailCode.build(FailCode.getTypeFromConnectionMode(sfs.getConnectionMode()),512,524288);
|
||||
var _loc2_:SFSEvent = new SFSEvent("onConnection",_loc3_);
|
||||
sfs.dispatchEvent(_loc2_);
|
||||
}
|
||||
|
||||
public function handleLoginOk(param1:Object) : void
|
||||
{
|
||||
var _loc2_:int = int(param1.body.login.@id);
|
||||
var _loc4_:int = int(param1.body.login.@mod);
|
||||
var _loc5_:String = param1.body.login.@n;
|
||||
sfs.amIModerator = _loc4_ == 1;
|
||||
sfs.myUserId = _loc2_;
|
||||
sfs.myUserName = _loc5_;
|
||||
sfs.playerId = -1;
|
||||
var _loc6_:Object = {};
|
||||
_loc6_.success = true;
|
||||
_loc6_.name = _loc5_;
|
||||
_loc6_.error = "";
|
||||
var _loc3_:SFSEvent = new SFSEvent("onLogin",_loc6_);
|
||||
sfs.dispatchEvent(_loc3_);
|
||||
}
|
||||
|
||||
public function handleLoginKo(param1:Object) : void
|
||||
{
|
||||
var _loc3_:Object = {};
|
||||
_loc3_.success = false;
|
||||
_loc3_.error = param1.body.login.@e;
|
||||
var _loc2_:SFSEvent = new SFSEvent("onLogin",_loc3_);
|
||||
sfs.dispatchEvent(_loc2_);
|
||||
}
|
||||
|
||||
public function handleLogout(param1:Object) : void
|
||||
{
|
||||
sfs.__logout();
|
||||
var _loc2_:SFSEvent = new SFSEvent("onLogout",{});
|
||||
sfs.dispatchEvent(_loc2_);
|
||||
}
|
||||
|
||||
public function handleRoomList(param1:Object) : void
|
||||
{
|
||||
var _loc8_:int = 0;
|
||||
var _loc9_:Room = null;
|
||||
var _loc4_:Room = null;
|
||||
var _loc6_:Array = sfs.getAllRooms();
|
||||
var _loc7_:Array = [];
|
||||
for each(var _loc3_:XML in param1.body.rmList.rm)
|
||||
{
|
||||
_loc8_ = int(_loc3_.@id);
|
||||
_loc9_ = new Room(_loc8_,_loc3_.n,int(_loc3_.@maxu),int(_loc3_.@maxs),_loc3_.@temp == "1",_loc3_.@game == "1",_loc3_.@priv == "1",_loc3_.@lmb == "1",int(_loc3_.@ucnt),int(_loc3_.@scnt));
|
||||
if(_loc3_.vars.toString().length > 0)
|
||||
{
|
||||
populateVariables(_loc9_.getVariables(),_loc3_);
|
||||
}
|
||||
_loc4_ = _loc6_[_loc8_];
|
||||
if(_loc4_ != null)
|
||||
{
|
||||
_loc9_.setVariables(_loc4_.getVariables());
|
||||
_loc9_.setUserList(_loc4_.getUserList());
|
||||
}
|
||||
_loc7_[_loc8_] = _loc9_;
|
||||
}
|
||||
sfs.setRoomList(_loc7_);
|
||||
var _loc5_:Object = {};
|
||||
_loc5_.roomList = _loc7_;
|
||||
var _loc2_:SFSEvent = new SFSEvent("onRoomListUpdate",_loc5_);
|
||||
sfs.dispatchEvent(_loc2_);
|
||||
}
|
||||
|
||||
public function handleUserCountChange(param1:Object) : void
|
||||
{
|
||||
var _loc4_:Object = null;
|
||||
var _loc3_:SFSEvent = null;
|
||||
var _loc2_:int = int(param1.body.@u);
|
||||
var _loc5_:int = int(param1.body.@s);
|
||||
var _loc6_:int = int(param1.body.@r);
|
||||
var _loc7_:Room = sfs.getAllRooms()[_loc6_];
|
||||
if(_loc7_ != null)
|
||||
{
|
||||
_loc7_.setUserCount(_loc2_);
|
||||
_loc7_.setSpectatorCount(_loc5_);
|
||||
_loc4_ = {};
|
||||
_loc4_.room = _loc7_;
|
||||
_loc3_ = new SFSEvent("onUserCountChange",_loc4_);
|
||||
sfs.dispatchEvent(_loc3_);
|
||||
}
|
||||
}
|
||||
|
||||
public function handleJoinOk(param1:Object) : void
|
||||
{
|
||||
var _loc12_:String = null;
|
||||
var _loc13_:int = 0;
|
||||
var _loc4_:Boolean = false;
|
||||
var _loc7_:Boolean = false;
|
||||
var _loc5_:int = 0;
|
||||
var _loc14_:User = null;
|
||||
var _loc8_:int = int(param1.body.@r);
|
||||
var _loc3_:XMLList = param1.body;
|
||||
var _loc10_:XMLList = param1.body.uLs.u;
|
||||
var _loc15_:int = int(param1.body.pid.@id);
|
||||
sfs.activeRoomId = _loc8_;
|
||||
var _loc9_:Room = sfs.getRoom(_loc8_);
|
||||
_loc9_.clearUserList();
|
||||
sfs.playerId = _loc15_;
|
||||
_loc9_.setMyPlayerIndex(_loc15_);
|
||||
if(_loc3_.vars.toString().length > 0)
|
||||
{
|
||||
}
|
||||
_loc9_.clearVariables();
|
||||
populateVariables(_loc9_.getVariables(),_loc3_);
|
||||
for each(var _loc11_:XML in _loc10_)
|
||||
{
|
||||
_loc12_ = _loc11_.n;
|
||||
_loc13_ = int(_loc11_.@i);
|
||||
_loc4_ = _loc11_.@m == "1" ? true : false;
|
||||
_loc7_ = _loc11_.@s == "1" ? true : false;
|
||||
_loc5_ = int(_loc11_.@p == null ? -1 : int(_loc11_.@p));
|
||||
_loc14_ = new User(_loc13_,_loc12_);
|
||||
_loc14_.setModerator(_loc4_);
|
||||
_loc14_.setIsSpectator(_loc7_);
|
||||
_loc14_.setPlayerId(_loc5_);
|
||||
if(_loc11_.vars.toString().length > 0)
|
||||
{
|
||||
populateVariables(_loc14_.getVariables(),_loc11_);
|
||||
}
|
||||
_loc9_.addUser(_loc14_,_loc13_);
|
||||
}
|
||||
sfs.changingRoom = false;
|
||||
var _loc6_:Object = {};
|
||||
_loc6_.room = _loc9_;
|
||||
var _loc2_:SFSEvent = new SFSEvent("onJoinRoom",_loc6_);
|
||||
sfs.dispatchEvent(_loc2_);
|
||||
}
|
||||
|
||||
public function handleJoinKo(param1:Object) : void
|
||||
{
|
||||
sfs.changingRoom = false;
|
||||
var _loc3_:Object = {};
|
||||
_loc3_.error = param1.body.error.@msg;
|
||||
var _loc2_:SFSEvent = new SFSEvent("onJoinRoomError",_loc3_);
|
||||
sfs.dispatchEvent(_loc2_);
|
||||
}
|
||||
|
||||
public function handleUserEnterRoom(param1:Object) : void
|
||||
{
|
||||
var _loc10_:int = int(param1.body.@r);
|
||||
var _loc6_:int = int(param1.body.u.@i);
|
||||
var _loc11_:String = param1.body.u.n;
|
||||
var _loc3_:Boolean = param1.body.u.@m == "1";
|
||||
var _loc9_:Boolean = param1.body.u.@s == "1";
|
||||
var _loc7_:int = int(param1.body.u.@p != null ? int(param1.body.u.@p) : -1);
|
||||
var _loc4_:XMLList = param1.body.u.vars["var"];
|
||||
var _loc12_:Room = sfs.getRoom(_loc10_);
|
||||
var _loc5_:User = new User(_loc6_,_loc11_);
|
||||
_loc5_.setModerator(_loc3_);
|
||||
_loc5_.setIsSpectator(_loc9_);
|
||||
_loc5_.setPlayerId(_loc7_);
|
||||
_loc12_.addUser(_loc5_,_loc6_);
|
||||
if(param1.body.u.vars.toString().length > 0)
|
||||
{
|
||||
populateVariables(_loc5_.getVariables(),param1.body.u);
|
||||
}
|
||||
var _loc8_:Object = {};
|
||||
_loc8_.roomId = _loc10_;
|
||||
_loc8_.user = _loc5_;
|
||||
var _loc2_:SFSEvent = new SFSEvent("onUserEnterRoom",_loc8_);
|
||||
sfs.dispatchEvent(_loc2_);
|
||||
}
|
||||
|
||||
public function handleUserLeaveRoom(param1:Object) : void
|
||||
{
|
||||
var _loc5_:int = int(param1.body.user.@id);
|
||||
var _loc7_:int = int(param1.body.@r);
|
||||
var _loc6_:Room = sfs.getRoom(_loc7_);
|
||||
if(_loc6_ == null)
|
||||
{
|
||||
trace("WARN - Leave Room not found, id: " + _loc7_);
|
||||
return;
|
||||
}
|
||||
var _loc3_:String = _loc6_.getUser(_loc5_).getName();
|
||||
_loc6_.removeUser(_loc5_);
|
||||
var _loc4_:Object = {};
|
||||
_loc4_.roomId = _loc7_;
|
||||
_loc4_.userId = _loc5_;
|
||||
_loc4_.userName = _loc3_;
|
||||
var _loc2_:SFSEvent = new SFSEvent("onUserLeaveRoom",_loc4_);
|
||||
sfs.dispatchEvent(_loc2_);
|
||||
}
|
||||
|
||||
public function handlePublicMessage(param1:Object) : void
|
||||
{
|
||||
var _loc7_:int = int(param1.body.@r);
|
||||
var _loc6_:int = int(param1.body.user.@id);
|
||||
var _loc4_:String = param1.body.txt;
|
||||
var _loc3_:User = sfs.getRoom(_loc7_).getUser(_loc6_);
|
||||
var _loc5_:Object = {};
|
||||
_loc5_.message = Entities.decodeEntities(_loc4_);
|
||||
_loc5_.sender = _loc3_;
|
||||
_loc5_.roomId = _loc7_;
|
||||
var _loc2_:SFSEvent = new SFSEvent("onPublicMessage",_loc5_);
|
||||
sfs.dispatchEvent(_loc2_);
|
||||
}
|
||||
|
||||
public function handlePrivateMessage(param1:Object) : void
|
||||
{
|
||||
var _loc8_:int = int(param1.body.@r);
|
||||
var _loc6_:int = int(param1.body.user.@id);
|
||||
var _loc4_:String = param1.body.txt;
|
||||
var _loc7_:Room = sfs.getRoom(_loc8_);
|
||||
var _loc3_:User = null;
|
||||
if(_loc7_ != null)
|
||||
{
|
||||
_loc3_ = _loc7_.getUser(_loc6_);
|
||||
}
|
||||
var _loc5_:Object = {};
|
||||
_loc5_.message = Entities.decodeEntities(_loc4_);
|
||||
_loc5_.sender = _loc3_;
|
||||
_loc5_.roomId = _loc8_;
|
||||
_loc5_.userId = _loc6_;
|
||||
var _loc2_:SFSEvent = new SFSEvent("onPrivateMessage",_loc5_);
|
||||
sfs.dispatchEvent(_loc2_);
|
||||
}
|
||||
|
||||
public function handleAdminMessage(param1:Object) : void
|
||||
{
|
||||
var _loc6_:int = int(param1.body.@r);
|
||||
var _loc5_:int = int(param1.body.user.@id);
|
||||
var _loc3_:String = param1.body.txt;
|
||||
var _loc4_:Object = {};
|
||||
_loc4_.message = Entities.decodeEntities(_loc3_);
|
||||
var _loc2_:SFSEvent = new SFSEvent("onAdminMessage",_loc4_);
|
||||
sfs.dispatchEvent(_loc2_);
|
||||
}
|
||||
|
||||
public function handleModMessage(param1:Object) : void
|
||||
{
|
||||
var _loc7_:int = int(param1.body.@r);
|
||||
var _loc6_:int = int(param1.body.user.@id);
|
||||
var _loc4_:String = param1.body.txt;
|
||||
var _loc3_:User = null;
|
||||
var _loc8_:Room = sfs.getRoom(_loc7_);
|
||||
if(_loc8_ != null)
|
||||
{
|
||||
_loc3_ = _loc8_.getUser(_loc6_);
|
||||
}
|
||||
var _loc5_:Object = {};
|
||||
_loc5_.message = Entities.decodeEntities(_loc4_);
|
||||
_loc5_.sender = _loc3_;
|
||||
var _loc2_:SFSEvent = new SFSEvent("onModMessage",_loc5_);
|
||||
sfs.dispatchEvent(_loc2_);
|
||||
}
|
||||
|
||||
public function handleASObject(param1:Object) : void
|
||||
{
|
||||
var _loc8_:int = int(param1.body.@r);
|
||||
var _loc6_:int = int(param1.body.user.@id);
|
||||
var _loc7_:String = param1.body.dataObj;
|
||||
var _loc3_:User = sfs.getRoom(_loc8_).getUser(_loc6_);
|
||||
var _loc4_:Object = ObjectSerializer.getInstance().deserialize(new XML(_loc7_));
|
||||
var _loc5_:Object = {};
|
||||
_loc5_.obj = _loc4_;
|
||||
_loc5_.sender = _loc3_;
|
||||
var _loc2_:SFSEvent = new SFSEvent("onObjectReceived",_loc5_);
|
||||
sfs.dispatchEvent(_loc2_);
|
||||
}
|
||||
|
||||
public function handleRoomVarsUpdate(param1:Object) : void
|
||||
{
|
||||
var _loc4_:Object = null;
|
||||
var _loc2_:SFSEvent = null;
|
||||
var _loc7_:int = int(param1.body.@r);
|
||||
var _loc5_:int = int(param1.body.user.@id);
|
||||
var _loc6_:Room = sfs.getRoom(_loc7_);
|
||||
var _loc3_:Array = [];
|
||||
if(_loc6_ != null)
|
||||
{
|
||||
if(param1.body.vars.toString().length > 0)
|
||||
{
|
||||
populateVariables(_loc6_.getVariables(),param1.body,_loc3_);
|
||||
}
|
||||
_loc4_ = {};
|
||||
_loc4_.room = _loc6_;
|
||||
_loc4_.changedVars = _loc3_;
|
||||
_loc2_ = new SFSEvent("onRoomVariablesUpdate",_loc4_);
|
||||
sfs.dispatchEvent(_loc2_);
|
||||
}
|
||||
}
|
||||
|
||||
public function handleUserVarsUpdate(param1:Object) : void
|
||||
{
|
||||
var _loc3_:Array = null;
|
||||
var _loc5_:Object = null;
|
||||
var _loc2_:SFSEvent = null;
|
||||
var _loc6_:int = int(param1.body.user.@id);
|
||||
var _loc4_:User = null;
|
||||
var _loc8_:User = null;
|
||||
if(param1.body.vars.toString().length > 0)
|
||||
{
|
||||
for each(var _loc7_:Room in sfs.getAllRooms())
|
||||
{
|
||||
_loc4_ = _loc7_.getUser(_loc6_);
|
||||
if(_loc4_ != null)
|
||||
{
|
||||
if(_loc8_ == null)
|
||||
{
|
||||
_loc8_ = _loc4_;
|
||||
}
|
||||
_loc3_ = [];
|
||||
populateVariables(_loc4_.getVariables(),param1.body,_loc3_);
|
||||
}
|
||||
}
|
||||
_loc5_ = {};
|
||||
_loc5_.user = _loc8_;
|
||||
_loc5_.changedVars = _loc3_;
|
||||
_loc2_ = new SFSEvent("onUserVariablesUpdate",_loc5_);
|
||||
sfs.dispatchEvent(_loc2_);
|
||||
}
|
||||
}
|
||||
|
||||
private function handleRoomAdded(param1:Object) : void
|
||||
{
|
||||
var _loc6_:int = int(param1.body.rm.@id);
|
||||
var _loc8_:String = param1.body.rm.name;
|
||||
var _loc5_:int = int(param1.body.rm.@max);
|
||||
var _loc2_:int = int(param1.body.rm.@spec);
|
||||
var _loc9_:Boolean = param1.body.rm.@temp == "1" ? true : false;
|
||||
var _loc13_:Boolean = param1.body.rm.@game == "1" ? true : false;
|
||||
var _loc12_:Boolean = param1.body.rm.@priv == "1" ? true : false;
|
||||
var _loc10_:Boolean = param1.body.rm.@limbo == "1" ? true : false;
|
||||
var _loc3_:Room = new Room(_loc6_,_loc8_,_loc5_,_loc2_,_loc9_,_loc13_,_loc12_,_loc10_);
|
||||
var _loc11_:Array = sfs.getAllRooms();
|
||||
_loc11_[_loc6_] = _loc3_;
|
||||
if(param1.body.rm.vars.toString().length > 0)
|
||||
{
|
||||
populateVariables(_loc3_.getVariables(),param1.body.rm);
|
||||
}
|
||||
var _loc7_:Object = {};
|
||||
_loc7_.room = _loc3_;
|
||||
var _loc4_:SFSEvent = new SFSEvent("onRoomAdded",_loc7_);
|
||||
sfs.dispatchEvent(_loc4_);
|
||||
}
|
||||
|
||||
private function handleRoomDeleted(param1:Object) : void
|
||||
{
|
||||
var _loc3_:Object = null;
|
||||
var _loc2_:SFSEvent = null;
|
||||
var _loc4_:int = int(param1.body.rm.@id);
|
||||
var _loc5_:Array = sfs.getAllRooms();
|
||||
if(_loc5_[_loc4_] != null)
|
||||
{
|
||||
_loc3_ = {};
|
||||
_loc3_.room = _loc5_[_loc4_];
|
||||
delete _loc5_[_loc4_];
|
||||
_loc2_ = new SFSEvent("onRoomDeleted",_loc3_);
|
||||
sfs.dispatchEvent(_loc2_);
|
||||
}
|
||||
}
|
||||
|
||||
private function handleRandomKey(param1:Object) : void
|
||||
{
|
||||
var _loc4_:String = param1.body.k.toString();
|
||||
var _loc3_:Object = {};
|
||||
_loc3_.key = _loc4_;
|
||||
var _loc2_:SFSEvent = new SFSEvent("onRandomKey",_loc3_);
|
||||
sfs.dispatchEvent(_loc2_);
|
||||
}
|
||||
|
||||
private function handleRoundTripBench(param1:Object) : void
|
||||
{
|
||||
var _loc4_:int = getTimer();
|
||||
var _loc2_:int = _loc4_ - sfs.getBenchStartTime();
|
||||
var _loc5_:Object = {};
|
||||
_loc5_.elapsed = _loc2_;
|
||||
var _loc3_:SFSEvent = new SFSEvent("onRoundTripResponse",_loc5_);
|
||||
sfs.dispatchEvent(_loc3_);
|
||||
}
|
||||
|
||||
private function handleCreateRoomError(param1:Object) : void
|
||||
{
|
||||
var _loc3_:String = param1.body.room.@e;
|
||||
var _loc4_:Object = {};
|
||||
_loc4_.error = _loc3_;
|
||||
var _loc2_:SFSEvent = new SFSEvent("onCreateRoomError",_loc4_);
|
||||
sfs.dispatchEvent(_loc2_);
|
||||
}
|
||||
|
||||
private function handleBuddyList(param1:Object) : void
|
||||
{
|
||||
var _loc10_:Object = null;
|
||||
var _loc5_:XMLList = null;
|
||||
var _loc7_:XMLList = param1.body.bList;
|
||||
var _loc8_:XMLList = param1.body.mv;
|
||||
var _loc9_:Object = {};
|
||||
var _loc2_:SFSEvent = null;
|
||||
if(_loc8_ != null && _loc8_.toString().length > 0)
|
||||
{
|
||||
for each(var _loc4_:XML in _loc8_.v)
|
||||
{
|
||||
sfs.myBuddyVars[_loc4_.@n.toString()] = _loc4_.toString();
|
||||
}
|
||||
}
|
||||
if(_loc7_ != null && _loc7_.b.length != null)
|
||||
{
|
||||
if(_loc7_.toString().length > 0)
|
||||
{
|
||||
for each(var _loc3_:XML in _loc7_.b)
|
||||
{
|
||||
_loc10_ = {};
|
||||
_loc10_.isOnline = _loc3_.@s == "1" ? true : false;
|
||||
_loc10_.name = _loc3_.n.toString();
|
||||
_loc10_.id = _loc3_.@i;
|
||||
_loc10_.isBlocked = _loc3_.@x == "1" ? true : false;
|
||||
_loc10_.variables = {};
|
||||
_loc5_ = _loc3_.vs;
|
||||
if(_loc5_.toString().length > 0)
|
||||
{
|
||||
for each(var _loc6_:XML in _loc5_.v)
|
||||
{
|
||||
_loc10_.variables[_loc6_.@n.toString()] = _loc6_.toString();
|
||||
}
|
||||
}
|
||||
sfs.buddyList.push(_loc10_);
|
||||
}
|
||||
}
|
||||
_loc9_.list = sfs.buddyList;
|
||||
_loc2_ = new SFSEvent("onBuddyList",_loc9_);
|
||||
sfs.dispatchEvent(_loc2_);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc9_.error = param1.body.err.toString();
|
||||
_loc2_ = new SFSEvent("onBuddyListError",_loc9_);
|
||||
sfs.dispatchEvent(_loc2_);
|
||||
}
|
||||
}
|
||||
|
||||
private function handleBuddyListUpdate(param1:Object) : void
|
||||
{
|
||||
var _loc9_:Object = null;
|
||||
var _loc3_:XMLList = null;
|
||||
var _loc8_:Object = null;
|
||||
var _loc4_:Boolean = false;
|
||||
var _loc7_:Object = {};
|
||||
var _loc2_:SFSEvent = null;
|
||||
if(param1.body.err.toString().length > 0)
|
||||
{
|
||||
_loc7_.error = param1.body.err.toString();
|
||||
_loc2_ = new SFSEvent("onBuddyListError",_loc7_);
|
||||
sfs.dispatchEvent(_loc2_);
|
||||
return;
|
||||
}
|
||||
if(param1.body.b != null)
|
||||
{
|
||||
_loc9_ = {};
|
||||
_loc9_.isOnline = param1.body.b.@s == "1" ? true : false;
|
||||
_loc9_.name = param1.body.b.n.toString();
|
||||
_loc9_.id = param1.body.b.@i;
|
||||
_loc9_.isBlocked = param1.body.b.@x == "1" ? true : false;
|
||||
_loc3_ = param1.body.b.vs;
|
||||
_loc8_ = null;
|
||||
_loc4_ = false;
|
||||
for(var _loc6_:String in sfs.buddyList)
|
||||
{
|
||||
_loc8_ = sfs.buddyList[_loc6_];
|
||||
if(_loc8_.name == _loc9_.name)
|
||||
{
|
||||
sfs.buddyList[_loc6_] = _loc9_;
|
||||
_loc9_.isBlocked = _loc8_.isBlocked;
|
||||
_loc9_.variables = _loc8_.variables;
|
||||
if(_loc3_.toString().length > 0)
|
||||
{
|
||||
for each(var _loc5_:XML in _loc3_.v)
|
||||
{
|
||||
_loc9_.variables[_loc5_.@n.toString()] = _loc5_.toString();
|
||||
}
|
||||
}
|
||||
_loc4_ = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(_loc4_)
|
||||
{
|
||||
_loc7_.buddy = _loc9_;
|
||||
_loc2_ = new SFSEvent("onBuddyListUpdate",_loc7_);
|
||||
sfs.dispatchEvent(_loc2_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function handleAddBuddyPermission(param1:Object) : void
|
||||
{
|
||||
var _loc3_:Object = {};
|
||||
_loc3_.sender = param1.body.n.toString();
|
||||
_loc3_.message = "";
|
||||
if(param1.body.txt != undefined)
|
||||
{
|
||||
_loc3_.message = Entities.decodeEntities(param1.body.txt);
|
||||
}
|
||||
var _loc2_:SFSEvent = new SFSEvent("onBuddyPermissionRequest",_loc3_);
|
||||
sfs.dispatchEvent(_loc2_);
|
||||
}
|
||||
|
||||
private function handleBuddyAdded(param1:Object) : void
|
||||
{
|
||||
var _loc6_:Object = {};
|
||||
_loc6_.isOnline = param1.body.b.@s == "1" ? true : false;
|
||||
_loc6_.name = param1.body.b.n.toString();
|
||||
_loc6_.id = param1.body.b.@i;
|
||||
_loc6_.isBlocked = param1.body.b.@x == "1" ? true : false;
|
||||
_loc6_.variables = {};
|
||||
var _loc3_:XMLList = param1.body.b.vs;
|
||||
if(_loc3_.toString().length > 0)
|
||||
{
|
||||
for each(var _loc4_:XML in _loc3_.v)
|
||||
{
|
||||
_loc6_.variables[_loc4_.@n.toString()] = _loc4_.toString();
|
||||
}
|
||||
}
|
||||
sfs.buddyList.push(_loc6_);
|
||||
var _loc5_:Object = {};
|
||||
_loc5_.list = sfs.buddyList;
|
||||
var _loc2_:SFSEvent = new SFSEvent("onBuddyList",_loc5_);
|
||||
sfs.dispatchEvent(_loc2_);
|
||||
}
|
||||
|
||||
private function handleRemoveBuddy(param1:Object) : void
|
||||
{
|
||||
var _loc5_:Object = null;
|
||||
var _loc2_:SFSEvent = null;
|
||||
var _loc4_:String = param1.body.n.toString();
|
||||
var _loc6_:Object = null;
|
||||
for(var _loc3_:String in sfs.buddyList)
|
||||
{
|
||||
_loc6_ = sfs.buddyList[_loc3_];
|
||||
if(_loc6_.name == _loc4_)
|
||||
{
|
||||
delete sfs.buddyList[_loc3_];
|
||||
_loc5_ = {};
|
||||
_loc5_.list = sfs.buddyList;
|
||||
_loc2_ = new SFSEvent("onBuddyList",_loc5_);
|
||||
sfs.dispatchEvent(_loc2_);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function handleBuddyRoom(param1:Object) : void
|
||||
{
|
||||
var _loc5_:int = 0;
|
||||
var _loc2_:String = param1.body.br.@r;
|
||||
var _loc4_:Array = _loc2_.split(",");
|
||||
_loc5_ = 0;
|
||||
while(_loc5_ < _loc4_.length)
|
||||
{
|
||||
_loc4_[_loc5_] = int(_loc4_[_loc5_]);
|
||||
_loc5_++;
|
||||
}
|
||||
var _loc6_:Object = {};
|
||||
_loc6_.idList = _loc4_;
|
||||
var _loc3_:SFSEvent = new SFSEvent("onBuddyRoom",_loc6_);
|
||||
sfs.dispatchEvent(_loc3_);
|
||||
}
|
||||
|
||||
private function handleLeaveRoom(param1:Object) : void
|
||||
{
|
||||
var _loc4_:Object = null;
|
||||
var _loc2_:SFSEvent = null;
|
||||
var _loc3_:int = int(param1.body.rm.@id);
|
||||
var _loc5_:Array = sfs.getAllRooms();
|
||||
if(_loc5_[_loc3_])
|
||||
{
|
||||
_loc4_ = {};
|
||||
_loc4_.roomId = _loc3_;
|
||||
_loc2_ = new SFSEvent("onRoomLeft",_loc4_);
|
||||
sfs.dispatchEvent(_loc2_);
|
||||
}
|
||||
}
|
||||
|
||||
private function handleSpectatorSwitched(param1:Object) : void
|
||||
{
|
||||
var _loc5_:int = 0;
|
||||
var _loc6_:User = null;
|
||||
var _loc3_:Object = null;
|
||||
var _loc2_:SFSEvent = null;
|
||||
var _loc7_:int = int(param1.body.@r);
|
||||
var _loc8_:int = int(param1.body.pid.@id);
|
||||
var _loc4_:Room = sfs.getRoom(_loc7_);
|
||||
if(_loc8_ > 0)
|
||||
{
|
||||
_loc4_.setUserCount(_loc4_.getUserCount() + 1);
|
||||
_loc4_.setSpectatorCount(_loc4_.getSpectatorCount() - 1);
|
||||
}
|
||||
if(param1.body.pid.@u != undefined)
|
||||
{
|
||||
_loc5_ = int(param1.body.pid.@u);
|
||||
_loc6_ = _loc4_.getUser(_loc5_);
|
||||
if(_loc6_ != null)
|
||||
{
|
||||
_loc6_.setIsSpectator(false);
|
||||
_loc6_.setPlayerId(_loc8_);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sfs.playerId = _loc8_;
|
||||
_loc3_ = {};
|
||||
_loc3_.success = sfs.playerId > 0;
|
||||
_loc3_.newId = sfs.playerId;
|
||||
_loc3_.room = _loc4_;
|
||||
_loc2_ = new SFSEvent("onSpectatorSwitched",_loc3_);
|
||||
sfs.dispatchEvent(_loc2_);
|
||||
}
|
||||
}
|
||||
|
||||
private function handlePlayerSwitched(param1:Object) : void
|
||||
{
|
||||
var _loc6_:int = 0;
|
||||
var _loc7_:User = null;
|
||||
var _loc4_:Object = null;
|
||||
var _loc2_:SFSEvent = null;
|
||||
var _loc8_:int = int(param1.body.@r);
|
||||
var _loc9_:int = int(param1.body.pid.@id);
|
||||
var _loc3_:Boolean = param1.body.pid.@u == undefined;
|
||||
var _loc5_:Room = sfs.getRoom(_loc8_);
|
||||
if(_loc9_ == -1)
|
||||
{
|
||||
_loc5_.setUserCount(_loc5_.getUserCount() - 1);
|
||||
_loc5_.setSpectatorCount(_loc5_.getSpectatorCount() + 1);
|
||||
if(!_loc3_)
|
||||
{
|
||||
_loc6_ = int(param1.body.pid.@u);
|
||||
_loc7_ = _loc5_.getUser(_loc6_);
|
||||
if(_loc7_ != null)
|
||||
{
|
||||
_loc7_.setIsSpectator(true);
|
||||
_loc7_.setPlayerId(_loc9_);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(_loc3_)
|
||||
{
|
||||
sfs.playerId = _loc9_;
|
||||
_loc4_ = {};
|
||||
_loc4_.success = _loc9_ == -1;
|
||||
_loc4_.newId = _loc9_;
|
||||
_loc4_.room = _loc5_;
|
||||
_loc2_ = new SFSEvent("onPlayerSwitched",_loc4_);
|
||||
sfs.dispatchEvent(_loc2_);
|
||||
}
|
||||
}
|
||||
|
||||
private function populateVariables(param1:Array, param2:Object, param3:Array = null) : void
|
||||
{
|
||||
var _loc4_:String = null;
|
||||
var _loc6_:String = null;
|
||||
var _loc7_:String = null;
|
||||
for each(var _loc5_:XML in param2.vars["var"])
|
||||
{
|
||||
_loc4_ = _loc5_.@n;
|
||||
_loc6_ = _loc5_.@t;
|
||||
_loc7_ = _loc5_;
|
||||
if(param3 != null)
|
||||
{
|
||||
param3.push(_loc4_);
|
||||
param3[_loc4_] = true;
|
||||
}
|
||||
if(_loc6_ == "b")
|
||||
{
|
||||
param1[_loc4_] = _loc7_ == "1" ? true : false;
|
||||
}
|
||||
else if(_loc6_ == "n")
|
||||
{
|
||||
param1[_loc4_] = Number(_loc7_);
|
||||
}
|
||||
else if(_loc6_ == "s")
|
||||
{
|
||||
param1[_loc4_] = _loc7_;
|
||||
}
|
||||
else if(_loc6_ == "x")
|
||||
{
|
||||
delete param1[_loc4_];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function dispatchDisconnection() : void
|
||||
{
|
||||
var _loc1_:SFSEvent = new SFSEvent("onConnectionLost",null);
|
||||
sfs.dispatchEvent(_loc1_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,172 @@
|
||||
package it.gotoandplay.smartfoxserver.http
|
||||
{
|
||||
import flash.events.Event;
|
||||
import flash.events.EventDispatcher;
|
||||
import flash.events.HTTPStatusEvent;
|
||||
import flash.events.IOErrorEvent;
|
||||
import flash.net.URLLoader;
|
||||
import flash.net.URLRequest;
|
||||
import flash.net.URLVariables;
|
||||
import it.gotoandplay.smartfoxserver.SmartFoxClient;
|
||||
|
||||
public class HttpConnection extends EventDispatcher
|
||||
{
|
||||
|
||||
private static const HANDSHAKE:String = "connect";
|
||||
|
||||
private static const DISCONNECT:String = "disconnect";
|
||||
|
||||
private static const CONN_LOST:String = "ERR#01";
|
||||
|
||||
public static const POLL:String = "poll";
|
||||
|
||||
public static const HANDSHAKE_TOKEN:String = "#";
|
||||
|
||||
private static const servletUrl:String = "BlueBox/HttpBox.do";
|
||||
|
||||
private static const paramName:String = "sfsHttp";
|
||||
|
||||
private var smartFoxClient:SmartFoxClient;
|
||||
|
||||
private var sessionId:String;
|
||||
|
||||
private var connected:Boolean = false;
|
||||
|
||||
private var ipAddr:String;
|
||||
|
||||
private var port:int;
|
||||
|
||||
private var baseUrl:String;
|
||||
|
||||
private var webUrl:String;
|
||||
|
||||
private var urlRequest:URLRequest;
|
||||
|
||||
private var codec:IHttpProtocolCodec;
|
||||
|
||||
public function HttpConnection(param1:SmartFoxClient)
|
||||
{
|
||||
super();
|
||||
codec = new RawProtocolCodec();
|
||||
HttpRequest.init(handleResponse,handleStatus,handleIOError);
|
||||
this.smartFoxClient = param1;
|
||||
param1.debugMessage("HttpConnection ctor");
|
||||
}
|
||||
|
||||
public function getSessionId() : String
|
||||
{
|
||||
return this.sessionId;
|
||||
}
|
||||
|
||||
public function getBaseUrl() : String
|
||||
{
|
||||
return baseUrl;
|
||||
}
|
||||
|
||||
public function isConnected() : Boolean
|
||||
{
|
||||
return this.connected;
|
||||
}
|
||||
|
||||
public function connect(param1:String, param2:int = 8080, param3:Boolean = false) : void
|
||||
{
|
||||
this.ipAddr = param1;
|
||||
this.port = param2;
|
||||
this.baseUrl = (param3 ? "https://bb-" : "http://") + this.ipAddr;
|
||||
if(!param3 && param2 != 80 || param3 && param2 != 443)
|
||||
{
|
||||
this.baseUrl += ":" + this.port;
|
||||
}
|
||||
this.webUrl = baseUrl + "/" + "BlueBox/HttpBox.do";
|
||||
this.sessionId = null;
|
||||
urlRequest = new URLRequest(webUrl);
|
||||
urlRequest.method = "POST";
|
||||
smartFoxClient.debugMessage("connect: " + baseUrl);
|
||||
send("connect");
|
||||
}
|
||||
|
||||
public function close() : void
|
||||
{
|
||||
send("disconnect");
|
||||
}
|
||||
|
||||
public function send(param1:String) : void
|
||||
{
|
||||
var _loc2_:URLVariables = null;
|
||||
if(connected || param1 == "connect" || param1 == "poll")
|
||||
{
|
||||
_loc2_ = new URLVariables();
|
||||
_loc2_["sfsHttp"] = codec.encode(this.sessionId,param1);
|
||||
urlRequest.data = _loc2_;
|
||||
smartFoxClient.debugMessage("[Sending - BlueBox]: " + urlRequest.data);
|
||||
new HttpRequest(urlRequest,param1);
|
||||
}
|
||||
else
|
||||
{
|
||||
smartFoxClient.debugMessage("send: can\'t send message before being connected: " + param1);
|
||||
}
|
||||
}
|
||||
|
||||
private function handleResponse(param1:Event, param2:HttpRequest) : void
|
||||
{
|
||||
var _loc5_:HttpEvent = null;
|
||||
var _loc4_:URLLoader = param1.target as URLLoader;
|
||||
var _loc3_:String = _loc4_.data as String;
|
||||
var _loc6_:Object = {};
|
||||
if(_loc3_.charAt(0) == "#")
|
||||
{
|
||||
if(sessionId == null)
|
||||
{
|
||||
sessionId = codec.decode(_loc3_);
|
||||
connected = true;
|
||||
smartFoxClient.debugMessage("handleResponse: init sessionId: " + sessionId);
|
||||
_loc6_.sessionId = this.sessionId;
|
||||
_loc6_.success = true;
|
||||
_loc5_ = new HttpEvent("onHttpConnect",_loc6_);
|
||||
dispatchEvent(_loc5_);
|
||||
}
|
||||
else
|
||||
{
|
||||
smartFoxClient.debugMessage("**ERROR** SessionId is being rewritten");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(_loc3_.indexOf("ERR#01") == 0)
|
||||
{
|
||||
_loc6_.data = {};
|
||||
_loc5_ = new HttpEvent("onHttpClose",_loc6_);
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc6_.data = _loc3_;
|
||||
_loc5_ = new HttpEvent("onHttpData",_loc6_);
|
||||
}
|
||||
dispatchEvent(_loc5_);
|
||||
}
|
||||
}
|
||||
|
||||
private function handleStatus(param1:HTTPStatusEvent, param2:HttpRequest) : void
|
||||
{
|
||||
var _loc3_:HttpEvent = null;
|
||||
if(param1.status < 200 || param1.status >= 400)
|
||||
{
|
||||
if(param2.message == "poll")
|
||||
{
|
||||
param2.complete();
|
||||
_loc3_ = new HttpEvent("onHttpPollError",null);
|
||||
dispatchEvent(_loc3_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function handleIOError(param1:IOErrorEvent, param2:HttpRequest) : void
|
||||
{
|
||||
var _loc3_:Object = {};
|
||||
_loc3_.message = param1.text;
|
||||
var _loc4_:HttpEvent = new HttpEvent("onHttpError",_loc3_);
|
||||
dispatchEvent(_loc4_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package it.gotoandplay.smartfoxserver.http
|
||||
{
|
||||
import flash.events.Event;
|
||||
|
||||
public class HttpEvent extends Event
|
||||
{
|
||||
|
||||
public static const onHttpData:String = "onHttpData";
|
||||
|
||||
public static const onHttpError:String = "onHttpError";
|
||||
|
||||
public static const onHttpPollError:String = "onHttpPollError";
|
||||
|
||||
public static const onHttpConnect:String = "onHttpConnect";
|
||||
|
||||
public static const onHttpClose:String = "onHttpClose";
|
||||
|
||||
public var params:Object;
|
||||
|
||||
private var evtType:String;
|
||||
|
||||
public function HttpEvent(param1:String, param2:Object)
|
||||
{
|
||||
super(param1);
|
||||
this.params = param2;
|
||||
this.evtType = param1;
|
||||
}
|
||||
|
||||
override public function clone() : Event
|
||||
{
|
||||
return new HttpEvent(this.evtType,this.params);
|
||||
}
|
||||
|
||||
override public function toString() : String
|
||||
{
|
||||
return formatToString("HttpEvent","type","bubbles","cancelable","eventPhase","params");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
package it.gotoandplay.smartfoxserver.http
|
||||
{
|
||||
import flash.events.Event;
|
||||
import flash.events.HTTPStatusEvent;
|
||||
import flash.events.IOErrorEvent;
|
||||
import flash.net.URLLoader;
|
||||
import flash.net.URLRequest;
|
||||
|
||||
public class HttpRequest
|
||||
{
|
||||
|
||||
private static var _responseHandler:Function;
|
||||
|
||||
private static var _statusHandler:Function;
|
||||
|
||||
private static var _errorHandler:Function;
|
||||
|
||||
private var _message:String;
|
||||
|
||||
private var _status:int;
|
||||
|
||||
private var _isCompleted:Boolean;
|
||||
|
||||
public function HttpRequest(param1:URLRequest, param2:String)
|
||||
{
|
||||
super();
|
||||
_message = param2;
|
||||
var _loc3_:URLLoader = new URLLoader();
|
||||
_loc3_.dataFormat = "text";
|
||||
_loc3_.addEventListener("complete",handleResponse);
|
||||
_loc3_.addEventListener("httpStatus",handleStatus);
|
||||
_loc3_.addEventListener("ioError",handleIOError);
|
||||
_loc3_.load(param1);
|
||||
}
|
||||
|
||||
public static function init(param1:Function, param2:Function, param3:Function) : void
|
||||
{
|
||||
_responseHandler = param1;
|
||||
_statusHandler = param2;
|
||||
_errorHandler = param3;
|
||||
}
|
||||
|
||||
private function handleResponse(param1:Event) : void
|
||||
{
|
||||
_responseHandler(param1,this);
|
||||
}
|
||||
|
||||
private function handleStatus(param1:HTTPStatusEvent) : void
|
||||
{
|
||||
_status = param1.status;
|
||||
_statusHandler(param1,this);
|
||||
}
|
||||
|
||||
private function handleIOError(param1:IOErrorEvent) : void
|
||||
{
|
||||
if(!_isCompleted)
|
||||
{
|
||||
_errorHandler(param1,this);
|
||||
}
|
||||
}
|
||||
|
||||
public function get message() : String
|
||||
{
|
||||
return _message;
|
||||
}
|
||||
|
||||
public function get status() : int
|
||||
{
|
||||
return _status;
|
||||
}
|
||||
|
||||
public function complete() : void
|
||||
{
|
||||
_isCompleted = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
package it.gotoandplay.smartfoxserver.http
|
||||
{
|
||||
public interface IHttpProtocolCodec
|
||||
{
|
||||
|
||||
function encode(param1:String, param2:String) : String;
|
||||
|
||||
function decode(param1:String) : String;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package it.gotoandplay.smartfoxserver.http
|
||||
{
|
||||
public class RawProtocolCodec implements IHttpProtocolCodec
|
||||
{
|
||||
|
||||
private static const SESSION_ID_LEN:int = 32;
|
||||
|
||||
public function RawProtocolCodec()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public function encode(param1:String, param2:String) : String
|
||||
{
|
||||
return (param1 == null ? "" : param1) + param2;
|
||||
}
|
||||
|
||||
public function decode(param1:String) : String
|
||||
{
|
||||
var _loc2_:String = null;
|
||||
if(param1.charAt(0) == "#")
|
||||
{
|
||||
_loc2_ = param1.substr(1,32);
|
||||
}
|
||||
return _loc2_;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
package it.gotoandplay.smartfoxserver.util
|
||||
{
|
||||
public class Entities
|
||||
{
|
||||
|
||||
private static var ascTab:Array = [];
|
||||
|
||||
ascTab[">"] = ">";
|
||||
ascTab["<"] = "<";
|
||||
ascTab["&"] = "&";
|
||||
ascTab["\'"] = "'";
|
||||
ascTab["\""] = """;
|
||||
|
||||
private static var ascTabRev:Array = [];
|
||||
|
||||
ascTabRev[">"] = ">";
|
||||
ascTabRev["<"] = "<";
|
||||
ascTabRev["&"] = "&";
|
||||
ascTabRev["'"] = "\'";
|
||||
ascTabRev["""] = "\"";
|
||||
|
||||
private static var hexTable:Array = [];
|
||||
|
||||
hexTable["0"] = 0;
|
||||
hexTable["1"] = 1;
|
||||
hexTable["2"] = 2;
|
||||
hexTable["3"] = 3;
|
||||
hexTable["4"] = 4;
|
||||
hexTable["5"] = 5;
|
||||
hexTable["6"] = 6;
|
||||
hexTable["7"] = 7;
|
||||
hexTable["8"] = 8;
|
||||
hexTable["9"] = 9;
|
||||
hexTable["A"] = 10;
|
||||
hexTable["B"] = 11;
|
||||
hexTable["C"] = 12;
|
||||
hexTable["D"] = 13;
|
||||
hexTable["E"] = 14;
|
||||
hexTable["F"] = 15;
|
||||
|
||||
public function Entities()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function encodeEntities(param1:String) : String
|
||||
{
|
||||
var _loc4_:int = 0;
|
||||
var _loc2_:String = null;
|
||||
var _loc5_:int = 0;
|
||||
var _loc3_:String = "";
|
||||
_loc4_ = 0;
|
||||
while(_loc4_ < param1.length)
|
||||
{
|
||||
_loc2_ = param1.charAt(_loc4_);
|
||||
_loc5_ = param1.charCodeAt(_loc4_);
|
||||
if(_loc5_ == 9 || _loc5_ == 10 || _loc5_ == 13)
|
||||
{
|
||||
_loc3_ += _loc2_;
|
||||
}
|
||||
else if(_loc5_ >= 32 && _loc5_ <= 126)
|
||||
{
|
||||
if(ascTab[_loc2_] != null)
|
||||
{
|
||||
_loc3_ += ascTab[_loc2_];
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc3_ += _loc2_;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc3_ += _loc2_;
|
||||
}
|
||||
_loc4_++;
|
||||
}
|
||||
return _loc3_;
|
||||
}
|
||||
|
||||
public static function decodeEntities(param1:String) : String
|
||||
{
|
||||
var _loc5_:String = null;
|
||||
var _loc3_:String = null;
|
||||
var _loc7_:String = null;
|
||||
var _loc4_:String = null;
|
||||
var _loc2_:String = null;
|
||||
var _loc6_:int = 0;
|
||||
_loc5_ = "";
|
||||
while(_loc6_ < param1.length)
|
||||
{
|
||||
_loc3_ = param1.charAt(_loc6_);
|
||||
if(_loc3_ == "&")
|
||||
{
|
||||
_loc7_ = _loc3_;
|
||||
do
|
||||
{
|
||||
_loc6_++;
|
||||
_loc4_ = param1.charAt(_loc6_);
|
||||
_loc7_ += _loc4_;
|
||||
}
|
||||
while(_loc4_ != ";" && _loc6_ < param1.length);
|
||||
_loc2_ = ascTabRev[_loc7_];
|
||||
if(_loc2_ != null)
|
||||
{
|
||||
_loc5_ += _loc2_;
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc5_ += String.fromCharCode(getCharCode(_loc7_));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_loc5_ += _loc3_;
|
||||
}
|
||||
_loc6_++;
|
||||
}
|
||||
return _loc5_;
|
||||
}
|
||||
|
||||
public static function getCharCode(param1:String) : Number
|
||||
{
|
||||
var _loc2_:String = param1.substr(3,param1.length);
|
||||
_loc2_ = _loc2_.substr(0,_loc2_.length - 1);
|
||||
return Number("0x" + _loc2_);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
package it.gotoandplay.smartfoxserver.util
|
||||
{
|
||||
import flash.events.ErrorEvent;
|
||||
import flash.events.SecurityErrorEvent;
|
||||
|
||||
public class FailCode
|
||||
{
|
||||
|
||||
public static const TYPE_SOCKET:int = 1;
|
||||
|
||||
public static const TYPE_BLUEBOX:int = 2;
|
||||
|
||||
public static const PHASE_INIT:int = 256;
|
||||
|
||||
public static const PHASE_CONNECTED:int = 512;
|
||||
|
||||
public static const REASON_SECURITY:int = 65536;
|
||||
|
||||
public static const REASON_IO:int = 131072;
|
||||
|
||||
public static const REASON_PIN:int = 262144;
|
||||
|
||||
public static const REASON_API:int = 524288;
|
||||
|
||||
public static const REASON_POLL:int = 1048576;
|
||||
|
||||
public static const REASON_UNSUPPORTED:int = 2097152;
|
||||
|
||||
public function FailCode()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function build(param1:int, param2:int, param3:int) : int
|
||||
{
|
||||
return param1 | param2 | param3;
|
||||
}
|
||||
|
||||
public static function getReasonFromEvent(param1:ErrorEvent) : int
|
||||
{
|
||||
return param1 is SecurityErrorEvent ? 65536 : 131072;
|
||||
}
|
||||
|
||||
public static function getTypeFromConnectionMode(param1:String) : int
|
||||
{
|
||||
return param1 == "http" ? 2 : 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
package it.gotoandplay.smartfoxserver.util
|
||||
{
|
||||
public class ObjectSerializer
|
||||
{
|
||||
|
||||
private static var instance:ObjectSerializer;
|
||||
|
||||
private var debug:Boolean;
|
||||
|
||||
private var eof:String;
|
||||
|
||||
private var tabs:String;
|
||||
|
||||
public function ObjectSerializer(param1:Boolean = false)
|
||||
{
|
||||
super();
|
||||
this.tabs = "\t\t\t\t\t\t\t\t\t\t\t\t\t";
|
||||
setDebug(param1);
|
||||
}
|
||||
|
||||
public static function getInstance(param1:Boolean = false) : ObjectSerializer
|
||||
{
|
||||
if(instance == null)
|
||||
{
|
||||
instance = new ObjectSerializer(param1);
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
private function setDebug(param1:Boolean) : void
|
||||
{
|
||||
this.debug = param1;
|
||||
if(this.debug)
|
||||
{
|
||||
this.eof = "\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
this.eof = "";
|
||||
}
|
||||
}
|
||||
|
||||
public function serialize(param1:Object) : String
|
||||
{
|
||||
var _loc2_:Object = {};
|
||||
obj2xml(param1,_loc2_);
|
||||
return _loc2_.xmlStr;
|
||||
}
|
||||
|
||||
public function deserialize(param1:String) : Object
|
||||
{
|
||||
var _loc3_:XML = new XML(param1);
|
||||
var _loc2_:Object = {};
|
||||
xml2obj(_loc3_,_loc2_);
|
||||
return _loc2_;
|
||||
}
|
||||
|
||||
private function obj2xml(param1:Object, param2:Object, param3:int = 0, param4:String = "") : void
|
||||
{
|
||||
var _loc6_:String = null;
|
||||
var _loc5_:String = null;
|
||||
var _loc8_:* = undefined;
|
||||
if(param3 == 0)
|
||||
{
|
||||
param2.xmlStr = "<dataObj>" + this.eof;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(this.debug)
|
||||
{
|
||||
param2.xmlStr += this.tabs.substr(0,param3);
|
||||
}
|
||||
_loc6_ = param1 is Array ? "a" : "o";
|
||||
param2.xmlStr += "<obj t=\'" + _loc6_ + "\' o=\'" + param4 + "\'>" + this.eof;
|
||||
}
|
||||
for(var _loc7_:String in param1)
|
||||
{
|
||||
_loc5_ = typeof param1[_loc7_];
|
||||
_loc8_ = param1[_loc7_];
|
||||
if(_loc5_ == "boolean" || _loc5_ == "number" || _loc5_ == "string" || _loc5_ == "null")
|
||||
{
|
||||
if(_loc5_ == "boolean")
|
||||
{
|
||||
_loc8_ = Number(_loc8_);
|
||||
}
|
||||
else if(_loc5_ == "null")
|
||||
{
|
||||
_loc5_ = "x";
|
||||
_loc8_ = "";
|
||||
}
|
||||
else if(_loc5_ == "string")
|
||||
{
|
||||
_loc8_ = Entities.encodeEntities(_loc8_);
|
||||
}
|
||||
if(this.debug)
|
||||
{
|
||||
param2.xmlStr += this.tabs.substr(0,param3 + 1);
|
||||
}
|
||||
param2.xmlStr += "<var n=\'" + _loc7_ + "\' t=\'" + _loc5_.substr(0,1) + "\'>" + _loc8_ + "</var>" + this.eof;
|
||||
}
|
||||
else if(_loc5_ == "object")
|
||||
{
|
||||
obj2xml(_loc8_,param2,param3 + 1,_loc7_);
|
||||
if(this.debug)
|
||||
{
|
||||
param2.xmlStr += this.tabs.substr(0,param3 + 1);
|
||||
}
|
||||
param2.xmlStr += "</obj>" + this.eof;
|
||||
}
|
||||
}
|
||||
if(param3 == 0)
|
||||
{
|
||||
param2.xmlStr += "</dataObj>" + this.eof;
|
||||
}
|
||||
}
|
||||
|
||||
private function xml2obj(param1:XML, param2:Object) : void
|
||||
{
|
||||
var _loc3_:String = null;
|
||||
var _loc9_:String = null;
|
||||
var _loc10_:String = null;
|
||||
var _loc5_:String = null;
|
||||
var _loc6_:String = null;
|
||||
var _loc11_:String = null;
|
||||
var _loc8_:int = 0;
|
||||
var _loc7_:XMLList = param1.children();
|
||||
for each(var _loc4_:XML in _loc7_)
|
||||
{
|
||||
_loc3_ = _loc4_.name().toString();
|
||||
if(_loc3_ == "obj")
|
||||
{
|
||||
_loc9_ = _loc4_.@o;
|
||||
_loc10_ = _loc4_.@t;
|
||||
if(_loc10_ == "a")
|
||||
{
|
||||
param2[_loc9_] = [];
|
||||
}
|
||||
else if(_loc10_ == "o")
|
||||
{
|
||||
param2[_loc9_] = {};
|
||||
}
|
||||
xml2obj(_loc4_,param2[_loc9_]);
|
||||
}
|
||||
else if(_loc3_ == "var")
|
||||
{
|
||||
_loc5_ = _loc4_.@n;
|
||||
_loc6_ = _loc4_.@t;
|
||||
_loc11_ = _loc4_.toString();
|
||||
if(_loc6_ == "b")
|
||||
{
|
||||
param2[_loc5_] = _loc11_ == "0" ? false : true;
|
||||
}
|
||||
else if(_loc6_ == "n")
|
||||
{
|
||||
param2[_loc5_] = Number(_loc11_);
|
||||
}
|
||||
else if(_loc6_ == "s")
|
||||
{
|
||||
param2[_loc5_] = _loc11_;
|
||||
}
|
||||
else if(_loc6_ == "x")
|
||||
{
|
||||
param2[_loc5_] = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function encodeEntities(param1:String) : String
|
||||
{
|
||||
return param1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user