Brought up to date with the private repository (feea4c7)

This commit is contained in:
S committed 2026-10-14 20:57:33 +03:00
1 parent 1aa738d692
commit 1b1df1ae48
7925 files changed
+2617237 -20

No files matched your search

@@ -0,0 +1,163 @@
package com.sbi.client
{
import com.sbi.popup.SBOkPopup;
import flash.display.*;
import flash.events.*;
import flash.utils.Timer;
public class KeepAlive
{
public static var popupLayer:DisplayObjectContainer;
private static var _keepAliveTimer:Timer;
private static var _timeLeftTimer:Timer;
private static var _bInputReceived:Boolean;
private static var _mcsToKeepAlive:Array;
private static var _lastMsgSentToServer:Number;
private static var _inputTimer:Timer;
private static var _kickWarningPopupShowing:Boolean;
private static var _isConnected:Function;
private static var _disconnectClient:Function;
private static var _playIdleWarningSound:Function;
private static var KICK_INTERVAL:int = 300000;
private static var SEND_MSG_INTERVAL:int = 120000;
private static var NOTIFY_USER_INTERVAL:int = 10000;
private static var NOTIFY_USER_TIME:int = 30000;
public function KeepAlive()
{
super();
}
public static function init(param1:DisplayObjectContainer, param2:Function, param3:Function = null, param4:Function = null) : void
{
popupLayer = param1;
_keepAliveTimer = new Timer(SEND_MSG_INTERVAL);
_keepAliveTimer.addEventListener(TimerEvent.TIMER,sendKeepAliveMsg);
_timeLeftTimer = new Timer(NOTIFY_USER_INTERVAL);
_timeLeftTimer.addEventListener(TimerEvent.TIMER,timeLeftTimer);
_timeLeftTimer.start();
_lastMsgSentToServer = new Date().getTime();
_mcsToKeepAlive = new Array();
_isConnected = param2;
_disconnectClient = param3;
_playIdleWarningSound = param4;
}
public static function startKATimer(param1:DisplayObjectContainer) : void
{
param1.addEventListener(MouseEvent.MOUSE_DOWN,inputReceivedHandler,false,0,true);
param1.addEventListener(KeyboardEvent.KEY_DOWN,inputReceivedHandler,false,0,true);
_mcsToKeepAlive.push(param1);
_bInputReceived = true;
sendKeepAliveMsg(null);
_keepAliveTimer.start();
}
public static function stopKATimer(param1:DisplayObjectContainer) : void
{
gMainFrame.server.setXtObject_Str("ka",[],gMainFrame.server.isWorldZone);
_keepAliveTimer.stop();
var _loc2_:int = 0;
while(_loc2_ < _mcsToKeepAlive.length)
{
if(_mcsToKeepAlive[_loc2_] == param1)
{
_mcsToKeepAlive[_loc2_].removeEventListener(MouseEvent.MOUSE_DOWN,inputReceivedHandler);
_mcsToKeepAlive[_loc2_].removeEventListener(KeyboardEvent.KEY_DOWN,inputReceivedHandler);
_mcsToKeepAlive.splice(_loc2_,1);
break;
}
_loc2_++;
}
}
public static function restartTimeLeftTimer() : void
{
if(_timeLeftTimer)
{
_lastMsgSentToServer = new Date().getTime();
_timeLeftTimer.stop();
_timeLeftTimer.start();
}
}
private static function sendKeepAliveMsg(param1:TimerEvent) : void
{
if(_bInputReceived)
{
gMainFrame.server.setXtObject_Str("ka",[],gMainFrame.server.isWorldZone);
_lastMsgSentToServer = new Date().getTime();
_bInputReceived = false;
}
}
private static function timeLeftTimer(param1:TimerEvent) : void
{
var _loc3_:DisplayObject = null;
var _loc2_:Number = new Date().getTime() - _lastMsgSentToServer;
if(!_kickWarningPopupShowing && _loc2_ > KICK_INTERVAL - NOTIFY_USER_TIME)
{
_loc3_ = new SBOkPopup(popupLayer,"Are you still there? Click OK to keep playing.",true,onKickWarningPopup);
_kickWarningPopupShowing = true;
if(_playIdleWarningSound != null)
{
_playIdleWarningSound();
}
if(gMainFrame.userInfo.isModerator)
{
_bInputReceived = true;
sendKeepAliveMsg(null);
_kickWarningPopupShowing = false;
SBOkPopup.destroyInParentChain(_loc3_);
}
}
if(_loc2_ > KICK_INTERVAL)
{
if(_isConnected())
{
if(_disconnectClient != null)
{
_disconnectClient();
}
}
}
}
private static function onKickWarningPopup(param1:MouseEvent) : void
{
_bInputReceived = true;
sendKeepAliveMsg(null);
param1.stopPropagation();
SBOkPopup.destroyInParentChain(param1.target.parent);
_kickWarningPopupShowing = false;
}
public static function inputReceivedHandler(param1:Event) : void
{
if(!_bInputReceived)
{
_bInputReceived = true;
}
if(new Date().getTime() - _lastMsgSentToServer > SEND_MSG_INTERVAL)
{
sendKeepAliveMsg(null);
}
}
}
}
@@ -0,0 +1,962 @@
package com.sbi.client
{
import com.sbi.debug.DebugUtility;
import flash.events.EventDispatcher;
import flash.external.ExternalInterface;
import it.gotoandplay.smartfoxserver.SFSEvent;
import it.gotoandplay.smartfoxserver.SmartFoxClient;
import it.gotoandplay.smartfoxserver.data.Room;
import it.gotoandplay.smartfoxserver.data.User;
public class SFClient extends EventDispatcher
{
public static const STATUS_ONLINE:int = 1;
public static const STATUS_OFFLINE_ACTIVE:int = 0;
public static const STATUS_OFFLINE_ARCHIVED:int = -1;
public static const STATUS_OFFLINE_UNKNOWN:int = -2;
public static const INIT_ROOM_ID:int = 1;
protected var _sfs:SmartFoxClient;
protected var _serverIps:Array;
protected var _blueboxIps:Array;
protected var _serverIp:String;
protected var _serverPort:int;
private var _isConnected:Boolean;
private var _isLoggedIn:Boolean;
private var _isWorldLoggedIn:Boolean;
private var _currSubRoom:SFRoom;
private var _currRoom:SFRoom;
private var _currentPrimaryRoomId:int = -1;
private var _currentSubRoomId:int = -1;
private var _currentPrimaryRoomUsers:Object;
private var _currentSubRoomUsers:Object;
private var _triggerWhenWorldXtReadyCmd:String;
private var _triggerWhenWorldXtReadyObj:Array;
private var _roomIds:Array;
private var _userName:String;
private var _myUser:User;
private var _gemCount:int;
private var _password:String;
private var _zone:String;
private var _hashKey:String;
private var _isWorldZone:Boolean;
private var _pingTimeAvg:uint;
private var _pingTimeTotal:uint;
private var _pingTimeCount:uint;
public function SFClient()
{
super();
this._roomIds = new Array();
this.setUpServer();
}
private function setUpServer() : void
{
this._isConnected = false;
this._hashKey = null;
this._isLoggedIn = false;
this._isWorldLoggedIn = false;
this._sfs = new SmartFoxClient(false);
this._sfs.smartConnect = false;
this._sfs.addEventListener(SFSEvent.onConnection,this.onConnection);
this._sfs.addEventListener(SFSEvent.onConnectionLost,this.onConnectionLost);
this._sfs.addEventListener(SFSEvent.onLogin,this.onLogin);
this._sfs.addEventListener(SFSEvent.onExtensionResponse,this.onExtensionResponse);
this._sfs.addEventListener(SFSEvent.onLogout,this.onLogout);
this._sfs.addEventListener(SFSEvent.onRoomListUpdate,this.onRoomListUpdate);
this._sfs.addEventListener(SFSEvent.onRoomAdded,this.onRoomAdded);
this._sfs.addEventListener(SFSEvent.onCreateRoomError,this.onCreateRoomError);
this._sfs.addEventListener(SFSEvent.onRoomDeleted,this.onRoomDeleted);
this._sfs.addEventListener(SFSEvent.onUserEnterRoom,this.onUserEnterRoom);
this._sfs.addEventListener(SFSEvent.onUserLeaveRoom,this.onUserLeaveRoom);
this._sfs.addEventListener(SFSEvent.onRoomLeft,this.onRoomLeft);
this._sfs.addEventListener(SFSEvent.onUserCountChange,this.onUserCountChange);
this._sfs.addEventListener(SFSEvent.onBuddyList,this.onBuddyList);
this._sfs.addEventListener(SFSEvent.onBuddyListError,this.onBuddyListError);
this._sfs.addEventListener(SFSEvent.onBuddyListUpdate,this.onBuddyListUpdate);
this._sfs.addEventListener(SFSEvent.onBuddyPermissionRequest,this.onBuddyPermissionRequest);
this._sfs.addEventListener(SFSEvent.onBuddyRoom,this.onBuddyRoom);
this._sfs.addEventListener(SFSEvent.onAdminMessage,this.onAdminMessage);
this._sfs.addEventListener(SFSEvent.onModeratorMessage,this.onModeratorMessage);
this._sfs.addEventListener(SFSEvent.onPrivateMessage,this.onPrivateMessage);
this._sfs.addEventListener(SFSEvent.onPublicMessage,this.onPublicMessage);
this._sfs.addEventListener(SFSEvent.onRandomKey,this.onRandomKey);
}
public function setServerConfig(param1:Array, param2:int, param3:Array, param4:int, param5:String) : void
{
this._serverIps = param1;
this._serverIp = param1[0];
this._serverPort = param2;
this._blueboxIps = param3;
this._sfs.blueBoxIpAddress = param3[0];
this._sfs.blueBoxPort = param4;
this._sfs.debug = param5 == "true";
}
public function setNewServer(param1:int) : void
{
if(!this.autoAttemptHttp)
{
this._serverIp = this._serverIps[param1];
}
else
{
this._sfs.blueBoxIpAddress = this._serverIp = this._blueboxIps[param1];
}
}
public function switchServerNode(param1:String) : void
{
this._serverIp = param1;
if(this.autoAttemptHttp)
{
this._sfs.blueBoxIpAddress = this._serverIp;
}
}
public function isBlueboxMode() : Boolean
{
return this._sfs.getConnectionMode() == SmartFoxClient.CONNECTION_MODE_HTTP;
}
public function connect() : void
{
if(!this._isConnected)
{
this._sfs.connect(this._serverIp,this._serverPort);
}
else
{
this.getKey();
}
}
public function logIn(param1:String, param2:String, param3:String) : void
{
if(this._hashKey == null)
{
return;
}
this._userName = param2;
this._zone = param1;
this._isWorldZone = this._zone == "sbiLogin";
this._password = param3;
this._sfs.login(this._zone,param2,param3);
}
public function logOut() : void
{
this._sfs.logout();
}
public function disconnect() : void
{
this._isLoggedIn = false;
this._isWorldLoggedIn = false;
this._isConnected = false;
this._hashKey = null;
this._sfs.disconnect();
}
public function get serverIps() : Array
{
return this._serverIps;
}
public function get serverIp() : String
{
return this._serverIp;
}
public function get serverPort() : int
{
return this._sfs.port;
}
public function get blueboxIps() : Array
{
return this._blueboxIps;
}
public function get blueboxServerIp() : String
{
return this._sfs.blueBoxIpAddress;
}
public function get blueboxServerPort() : int
{
return this._sfs.blueBoxPort;
}
public function get isWorldXtReady() : Boolean
{
return this._isWorldLoggedIn;
}
public function triggerCmdWhenWorldXtReady(param1:String, param2:Array) : void
{
this._triggerWhenWorldXtReadyCmd = param1;
this._triggerWhenWorldXtReadyObj = param2;
}
public function triggerWorldXtReadyCmd() : void
{
if(this._triggerWhenWorldXtReadyCmd != null && this._triggerWhenWorldXtReadyObj != null)
{
this.setXtObject_Str(this._triggerWhenWorldXtReadyCmd,this._triggerWhenWorldXtReadyObj);
this._triggerWhenWorldXtReadyCmd = null;
this._triggerWhenWorldXtReadyObj = null;
}
}
public function setXtObject_Str(param1:String, param2:Array, param3:Boolean = true, param4:Boolean = false, param5:Boolean = true) : void
{
if(param2 == null)
{
param2 = [];
}
var _loc6_:String = param3 ? "o" : "a";
this._sfs.sendXtMessage(_loc6_,param1,param2,SmartFoxClient.XTMSG_TYPE_STR,this.getCurrentRoomId(param4));
if(param5)
{
KeepAlive.restartTimeLeftTimer();
}
}
public function setXtObject_XML(param1:String, param2:String, param3:Object, param4:Boolean = false) : void
{
if(param3 == null)
{
param3 = {};
}
this._sfs.sendXtMessage(param1,param2,param3,SmartFoxClient.XTMSG_TYPE_XML,this.getCurrentRoomId(param4));
}
public function setXtObject_JSON(param1:String, param2:Object, param3:Boolean = false) : void
{
if(param2 == null)
{
param2 = {};
}
this._sfs.sendXtMessage("a",param1,param2,SmartFoxClient.XTMSG_TYPE_JSON,this.getCurrentRoomId(param3));
}
public function getKey() : void
{
var _loc1_:SFEvent = null;
if(this._hashKey == null)
{
this._sfs.getRandomKey();
}
else
{
_loc1_ = new SFEvent(SFEvent.ON_CONNECT);
_loc1_.status = true;
dispatchEvent(_loc1_);
}
}
public function createRoom(param1:String, param2:uint, param3:uint, param4:Boolean, param5:Boolean, param6:String, param7:String) : void
{
throw new Error("createRoom on client should not be used if at all possible!");
}
public function setToJoinIRG(param1:Boolean) : void
{
this._currentSubRoomId = param1 ? 0 : -1;
}
public function leaveRoom(param1:int) : void
{
this._sfs.leaveRoom(param1);
}
public function leaveCurrentRoom(param1:Boolean = false) : void
{
this._sfs.leaveRoom(param1 ? this._currentSubRoomId : this._currentPrimaryRoomId);
this._currentSubRoomId = -1;
}
public function sendMessage(param1:String, param2:int = -2, param3:int = -1) : void
{
if(param3 >= 0)
{
this._sfs.sendPrivateMessage(param1,param3,param2);
}
else
{
if(param2 == -2)
{
param2 = this._currentPrimaryRoomId;
}
this._sfs.sendPublicMessage(param1,param2);
KeepAlive.restartTimeLeftTimer();
}
}
public function isInMyRoom(param1:int, param2:Boolean) : Boolean
{
if(!param2 && this._currentPrimaryRoomUsers == null)
{
return false;
}
if(param2 && this._currentSubRoomUsers == null)
{
return false;
}
return Boolean(param2 ? this._currentSubRoomUsers[param1] != undefined : this._currentPrimaryRoomUsers[param1] != undefined);
}
public function loadBuddyList() : void
{
this._sfs.loadBuddyList();
}
public function getBuddyById(param1:int) : Object
{
return this._sfs.getBuddyById(param1);
}
public function getBuddyByName(param1:String) : Object
{
return this._sfs.getBuddyByName(param1);
}
public function sendBuddyPermissionResponse(param1:Boolean, param2:String) : void
{
this._sfs.sendBuddyPermissionResponse(param1,param2);
}
public function setBuddyBlockStatus(param1:String, param2:Boolean) : void
{
this._sfs.setBuddyBlockStatus(param1,param2);
}
public function getBuddyRoomByName(param1:String) : void
{
var _loc2_:Object = this._sfs.getBuddyByName(param1);
this._sfs.getBuddyRoom(_loc2_);
}
public function getBuddyRoomById(param1:int) : void
{
var _loc2_:Object = this._sfs.getBuddyById(param1);
this._sfs.getBuddyRoom(_loc2_);
}
public function getBuddyRoom(param1:Object) : void
{
var _loc3_:Object = null;
if(!param1)
{
throw new Error("Invalid buddy obj used to request buddy room! userobj:" + param1);
}
if(!param1.hasOwnProperty("id"))
{
throw new Error("Invalid buddy obj used to request buddy room! userobj.hasOwnProperty(\"id\"):" + param1.hasOwnProperty("id"));
}
var _loc2_:Boolean = false;
for each(_loc3_ in this._sfs.buddyList)
{
if(_loc3_.id == param1.id)
{
_loc2_ = true;
break;
}
}
if(_loc2_)
{
this._sfs.getBuddyRoom(_loc3_);
return;
}
throw new Error("Invalid buddy obj used to request buddy room! Could not find match in client buddy list. userobj.id:" + param1.id);
}
public function removeBuddy(param1:String) : void
{
this._sfs.removeBuddy(param1);
}
public function getCurrentRoom(param1:Boolean = false) : SFRoom
{
return param1 ? this._currSubRoom : this._currRoom;
}
public function getCurrentRoomId(param1:Boolean = false) : int
{
if(!param1)
{
return this._currentPrimaryRoomId;
}
if(this._currentSubRoomId <= 0)
{
throw new Error("Attempt to send message to sub room without valid subRoomId! (no in-room game room currently joined?)");
}
return this._currentSubRoomId;
}
public function getPvpSubRoomId() : int
{
return this._currentSubRoomId;
}
public function setCurrSubRoomId(param1:int) : void
{
if(this._currentSubRoomId != -1)
{
DebugUtility.debugTrace("WARNING: setting currSubRoomId to " + param1 + " but _currSubRoomId was not -1. It was " + this._currentSubRoomId);
}
this._currentSubRoomId = param1;
}
public function getCurrentRoomName(param1:Boolean = false) : String
{
var _loc2_:SFRoom = this.getCurrentRoom(param1);
if(!_loc2_)
{
return null;
}
return _loc2_.name;
}
public function setInitRoom() : void
{
var _loc1_:Array = this._sfs.getAllRooms();
if(_loc1_.length > 0)
{
return;
}
_loc1_[INIT_ROOM_ID] = new Room(INIT_ROOM_ID,"_init",10000,0,false,false,false,true);
}
public function setRoomList(param1:Object) : void
{
var _loc6_:Room = null;
var _loc8_:int = 0;
var _loc2_:Array = this._sfs.getAllRooms();
_loc2_.splice(0,_loc2_.length);
var _loc3_:* = 2;
var _loc4_:int = int(param1[_loc3_++]);
var _loc5_:int = 0;
while(_loc5_ < _loc4_)
{
_loc8_ = int(param1[_loc3_++]);
_loc2_[_loc8_] = new Room(_loc8_,param1[_loc3_++],int(param1[_loc3_++]),0,param1[_loc3_++] == "1",param1[_loc3_++] == "1",false,_loc5_ < 1,int(param1[_loc3_++]));
_loc5_++;
}
this._roomIds.splice(0,this._roomIds.length);
for each(_loc6_ in _loc2_)
{
this._roomIds.push(_loc6_.getId());
}
if(this._currentPrimaryRoomId != -1)
{
this.setAPIUserList(this._currentPrimaryRoomId,this._currentPrimaryRoomUsers);
}
else if(this._roomIds.length == 1)
{
this._currentPrimaryRoomId = this.roomIds[0];
}
if(this._currentSubRoomId > 0)
{
this.setAPIUserList(this._currentSubRoomId,this._currentSubRoomUsers);
}
var _loc7_:SFEvent = new SFEvent(SFEvent.ON_ROOM_LIST);
_loc7_.status = true;
dispatchEvent(_loc7_);
}
public function setAPIUserList(param1:int, param2:Object) : void
{
var _loc5_:String = null;
var _loc3_:Room = this._sfs.getRoom(param1);
if(!_loc3_)
{
return;
}
var _loc4_:Array = _loc3_.getUserList();
if(!_loc4_)
{
return;
}
_loc4_.splice(0,_loc4_.length);
if(!param2)
{
return;
}
for(_loc5_ in param2)
{
_loc4_[_loc5_] = param2[_loc5_];
}
}
private function onConnection(param1:SFSEvent) : void
{
var _loc3_:SFEvent = null;
this._currentPrimaryRoomId = -1;
this._currentSubRoomId = -1;
if(ExternalInterface.available)
{
ExternalInterface.call("mrc",["dm","SFClient onConnection"]);
}
var _loc2_:Boolean = Boolean(param1.params.success);
if(_loc2_)
{
this._isConnected = true;
this.getKey();
}
else
{
_loc3_ = new SFEvent(SFEvent.ON_CONNECT);
_loc3_.status = false;
dispatchEvent(_loc3_);
}
}
private function onConnectionLost(param1:SFSEvent) : void
{
this._isConnected = false;
this._hashKey = null;
this._isLoggedIn = false;
this._isWorldLoggedIn = false;
this._currentPrimaryRoomId = -1;
this._currentSubRoomId = -1;
var _loc2_:SFEvent = new SFEvent(SFEvent.ON_CONNECTION_LOST);
_loc2_.status = true;
dispatchEvent(_loc2_);
}
private function onLogin(param1:SFSEvent) : void
{
var _loc2_:Boolean = Boolean(param1.params.success);
if(_loc2_)
{
this._isLoggedIn = true;
}
this._currentPrimaryRoomId = -1;
this._currentSubRoomId = -1;
var _loc3_:SFEvent = new SFEvent(SFEvent.ON_LOGIN);
_loc3_.status = _loc2_;
_loc3_.userName = param1.params.name;
dispatchEvent(_loc3_);
}
private function onExtensionResponse(param1:SFSEvent) : void
{
var _loc2_:Object = param1.params.dataObj;
var _loc3_:SFEvent = null;
if(_loc2_._cmd == "login")
{
if(ExternalInterface.available)
{
ExternalInterface.call("mrc",["dm","SFClient xtResponse - ON_LOGIN"]);
}
_loc3_ = new SFEvent(SFEvent.ON_LOGIN);
_loc3_.status = true;
_loc3_.obj = _loc2_.params;
this._currentPrimaryRoomId = -1;
this._currentSubRoomId = -1;
if(_loc2_.status == "1")
{
this._myUser = new User(this._sfs.myUserId = _loc2_.params.userId,this._sfs.myUserName = _loc2_.params.userName);
_loc3_.userName = _loc2_.params.userName;
this._isLoggedIn = true;
this._isWorldLoggedIn = true;
}
else
{
_loc3_.status = false;
_loc3_.message = _loc2_.message;
_loc3_.statusId = _loc2_.statusId;
}
dispatchEvent(_loc3_);
}
else
{
_loc3_ = new SFEvent(SFEvent.ON_XT_REPLY);
_loc3_.status = true;
_loc3_.obj = param1.params.dataObj;
dispatchEvent(_loc3_);
}
}
private function onLogout(param1:SFSEvent) : void
{
this._isLoggedIn = false;
this._isWorldLoggedIn = false;
var _loc2_:SFEvent = new SFEvent(SFEvent.ON_LOGOUT);
_loc2_.status = true;
dispatchEvent(_loc2_);
}
private function onRoomListUpdate(param1:SFSEvent) : void
{
var _loc2_:Room = null;
this._roomIds.splice(0,this._roomIds.length);
for each(_loc2_ in param1.params.roomList)
{
this._roomIds.push(_loc2_.getId());
}
if(this._currentPrimaryRoomId != -1)
{
this.setAPIUserList(this._currentPrimaryRoomId,this._currentPrimaryRoomUsers);
}
else if(this._roomIds.length == 1)
{
this._currentPrimaryRoomId = this.roomIds[0];
}
if(this._currentSubRoomId > 0)
{
this.setAPIUserList(this._currentSubRoomId,this._currentSubRoomUsers);
}
var _loc3_:SFEvent = new SFEvent(SFEvent.ON_ROOM_LIST);
_loc3_.status = true;
dispatchEvent(_loc3_);
}
private function onRoomAdded(param1:SFSEvent) : void
{
var _loc2_:SFEvent = new SFEvent(SFEvent.ON_ROOM_CREATED);
_loc2_.status = true;
_loc2_.roomId = param1.params.room.getId();
dispatchEvent(_loc2_);
}
private function onRoomDeleted(param1:SFSEvent) : void
{
this.setAPIUserList(this._currentPrimaryRoomId,this._currentPrimaryRoomUsers);
var _loc2_:SFEvent = new SFEvent(SFEvent.ON_ROOM_DELETED);
_loc2_.status = true;
if(Boolean(param1) && Boolean(param1.params) && Boolean(param1.params.room))
{
_loc2_.roomId = param1.params.room.getId();
}
dispatchEvent(_loc2_);
}
private function onCreateRoomError(param1:SFSEvent) : void
{
this._currentSubRoomUsers = null;
this.setAPIUserList(this._currentSubRoomId,this._currentSubRoomUsers);
this._currentSubRoomId = -1;
var _loc2_:SFEvent = new SFEvent(SFEvent.ON_ROOM_CREATED);
_loc2_.status = false;
_loc2_.message = param1.params.error;
dispatchEvent(_loc2_);
}
public function handleRoomJoin(param1:SFRoom) : void
{
var _loc4_:Room = null;
var _loc2_:int = param1.id;
if(this._currentSubRoomId == 0)
{
this._currSubRoom = param1;
this._currentSubRoomId = _loc2_;
}
else
{
this._currRoom = param1;
this._currentPrimaryRoomId = _loc2_;
}
if(ExternalInterface.available)
{
ExternalInterface.call("mrc",["dm","handleRoomJoin called"]);
}
var _loc3_:Array = this._sfs.getAllRooms();
(_loc3_[_loc2_] = new Room(_loc2_,param1.name,param1.maxUsers,param1.maxSpectators,param1.isTemp,param1.isGame,param1.isPrivate,param1.isLimbo,param1.users,param1.spectators)).addUser(this._myUser,this._myUser.getId());
this._sfs.activeRoomId = _loc2_;
var _loc5_:SFEvent = new SFEvent(SFEvent.ON_JOIN_ROOM);
_loc5_.status = true;
_loc5_.roomId = _loc2_;
_loc5_.obj = {};
_loc5_.obj.room = param1;
_loc5_.obj.subRoom = this._currSubRoom;
dispatchEvent(_loc5_);
}
public function handleRoomJoinError(param1:String, param2:String = "") : void
{
var _loc3_:SFEvent = new SFEvent(SFEvent.ON_JOIN_ROOM);
_loc3_.status = false;
_loc3_.message = param1;
_loc3_.obj = {};
_loc3_.obj.roomFull = param1 == "This room is currently full";
_loc3_.obj.denOwner = param2;
dispatchEvent(_loc3_);
}
public function handleSubRoomExit() : void
{
if(this._currentSubRoomId <= 0)
{
throw new Error("Trying to leave a sub room when not in one?");
}
this._currentSubRoomId = -1;
this._currSubRoom = null;
}
private function onRoomLeft(param1:SFSEvent) : void
{
if(this._currentSubRoomId == 0)
{
throw new Error("Left a room while in the middle of making a sub room?!");
}
if(param1.params.roomId == this._currentSubRoomId)
{
this._currentSubRoomUsers = null;
this._currentSubRoomId = -1;
}
else
{
this._currentPrimaryRoomUsers = null;
this.setAPIUserList(this._currentPrimaryRoomId,this._currentPrimaryRoomUsers);
}
var _loc2_:SFEvent = new SFEvent(SFEvent.ON_LEFT_ROOM);
_loc2_.status = true;
_loc2_.roomId = param1.params.roomId;
dispatchEvent(_loc2_);
}
private function onUserEnterRoom(param1:SFSEvent) : void
{
var _loc2_:SFEvent = new SFEvent(SFEvent.ON_USER_ENTERED_ROOM);
_loc2_.status = true;
_loc2_.userId = param1.params.user.getId();
_loc2_.userName = param1.params.user.getName();
_loc2_.roomId = param1.params.roomId;
if(_loc2_.roomId == this._currentPrimaryRoomId)
{
this._currentPrimaryRoomUsers[_loc2_.userId] = param1.params.user;
this.setAPIUserList(this._currentPrimaryRoomId,this._currentPrimaryRoomUsers);
}
else if(_loc2_.roomId == this._currentSubRoomId)
{
this._currentSubRoomUsers[_loc2_.userId] = param1.params.user;
this.setAPIUserList(this._currentSubRoomId,this._currentSubRoomUsers);
}
dispatchEvent(_loc2_);
}
private function onUserLeaveRoom(param1:SFSEvent) : void
{
var _loc2_:SFEvent = new SFEvent(SFEvent.ON_USER_LEFT_ROOM);
_loc2_.status = true;
_loc2_.userId = param1.params.userId;
_loc2_.roomId = param1.params.roomId;
if(_loc2_.roomId == this._currentPrimaryRoomId)
{
delete this._currentPrimaryRoomUsers[_loc2_.userId];
this.setAPIUserList(this._currentPrimaryRoomId,this._currentPrimaryRoomUsers);
}
else if(_loc2_.roomId == this._currentSubRoomId)
{
delete this._currentSubRoomUsers[_loc2_.userId];
this.setAPIUserList(this._currentSubRoomId,this._currentSubRoomUsers);
}
dispatchEvent(_loc2_);
}
private function onUserCountChange(param1:SFSEvent) : void
{
var _loc2_:SFEvent = new SFEvent(SFEvent.ON_ROOM_POPULATION_CHANGE);
_loc2_.status = true;
_loc2_.roomId = param1.params.room.getId();
dispatchEvent(_loc2_);
}
private function onBuddyList(param1:SFSEvent) : void
{
var _loc2_:SFEvent = new SFEvent(SFEvent.ON_BUDDY_LIST);
_loc2_.status = true;
_loc2_.obj = param1.params.list;
_loc2_.message = param1.params.error;
dispatchEvent(_loc2_);
}
private function onBuddyListError(param1:SFSEvent) : void
{
var _loc2_:SFEvent = new SFEvent(SFEvent.ON_BUDDY_LIST);
_loc2_.status = false;
_loc2_.message = param1.params.error;
dispatchEvent(_loc2_);
}
private function onBuddyListUpdate(param1:SFSEvent) : void
{
var _loc2_:SFEvent = new SFEvent(SFEvent.ON_BUDDY_LIST_UPDATE);
_loc2_.status = true;
_loc2_.userName = param1.params.buddy.name;
_loc2_.obj = param1.params.buddy;
_loc2_.message = param1.params.error;
dispatchEvent(_loc2_);
}
private function onBuddyPermissionRequest(param1:SFSEvent) : void
{
var _loc2_:SFEvent = new SFEvent(SFEvent.ON_BUDDY_REQUEST);
_loc2_.status = true;
_loc2_.userName = param1.params.sender;
dispatchEvent(_loc2_);
}
private function onBuddyRoom(param1:SFSEvent) : void
{
var _loc2_:SFEvent = new SFEvent(SFEvent.ON_BUDDY_ROOM);
_loc2_.status = true;
_loc2_.roomId = param1.params.idList[0];
dispatchEvent(_loc2_);
}
private function onAdminMessage(param1:SFSEvent) : void
{
DebugUtility.debugTrace("onAdminMessage:" + param1.params.message);
}
private function onModeratorMessage(param1:SFSEvent) : void
{
var _loc2_:SFEvent = new SFEvent(SFEvent.ON_CHAT_MESSAGE);
_loc2_.status = true;
_loc2_.message = param1.params.message;
dispatchEvent(_loc2_);
}
private function onPrivateMessage(param1:SFSEvent) : void
{
var _loc2_:SFEvent = new SFEvent(SFEvent.ON_CHAT_MESSAGE);
_loc2_.status = true;
_loc2_.message = param1.params.message;
dispatchEvent(_loc2_);
}
private function onPublicMessage(param1:SFSEvent) : void
{
var _loc2_:SFEvent = new SFEvent(SFEvent.ON_CHAT_MESSAGE);
_loc2_.status = true;
_loc2_.message = param1.params.message;
dispatchEvent(_loc2_);
}
private function onRandomKey(param1:SFSEvent) : void
{
this._hashKey = param1.params.key;
var _loc2_:SFEvent = new SFEvent(SFEvent.ON_CONNECT);
_loc2_.status = true;
dispatchEvent(_loc2_);
}
public function get autoAttemptHttp() : Boolean
{
return this._sfs.smartConnect;
}
public function set autoAttemptHttp(param1:Boolean) : void
{
this._sfs.smartConnect = param1;
}
public function get isWorldZone() : Boolean
{
return this._isWorldZone;
}
public function get userId() : int
{
return this._sfs.myUserId;
}
public function get userName() : String
{
return this._sfs.myUserName;
}
public function get gemCount() : int
{
return this._gemCount;
}
public function set gemCount(param1:int) : void
{
this._gemCount = param1;
}
public function get signInUserName() : String
{
return this._userName;
}
public function get password() : String
{
return this._password;
}
public function get roomIds() : Array
{
return this._roomIds;
}
public function get buddyList() : Array
{
return this._sfs.buddyList;
}
public function get rawProtocolSeparator() : String
{
return this._sfs.rawProtocolSeparator;
}
public function get isLoggedIn() : Boolean
{
return this._isLoggedIn;
}
public function get isConnected() : Boolean
{
return this._isConnected;
}
public function getIsConnected() : Boolean
{
return this._isConnected;
}
public function get hashKey() : String
{
return this._hashKey;
}
}
}
@@ -0,0 +1,75 @@
package com.sbi.client
{
import flash.events.Event;
public class SFEvent extends Event
{
public static const ON_CONNECT:String = "OnConnect";
public static const ON_LOGIN:String = "OnLogin";
public static const ON_LOGOUT:String = "OnLogOut";
public static const ON_CONNECTION_LOST:String = "OnConectionLost";
public static const ON_CHAT_MESSAGE:String = "OnChatMessage";
public static const ON_RECEIVED_OBJECT:String = "OnReceivedObject";
public static const ON_ROOM_LIST:String = "OnRoomList";
public static const ON_CREATE_ROOM:String = "OnCreateRoom";
public static const ON_ROOM_CREATED:String = "onRoomCreated";
public static const ON_JOIN_ROOM:String = "OnJoinRoom";
public static const ON_LEFT_ROOM:String = "OnLeftRoom";
public static const ON_USER_ENTERED_ROOM:String = "OnUserEnteredRoom";
public static const ON_USER_LEFT_ROOM:String = "OnUserLeftRoom";
public static const ON_ROOM_POPULATION_CHANGE:String = "onRoomPopulationChange";
public static const ON_BUDDY_LIST:String = "onBuddyList";
public static const ON_BUDDY_LIST_UPDATE:String = "onBuddyListUpdate";
public static const ON_BUDDY_REQUEST:String = "onBuddyRequest";
public static const ON_BUDDY_ROOM:String = "onBuddyRoom";
public static const ON_XT_REPLY:String = "OnXtReply";
public static const ON_ROOM_DELETED:String = "onRoomDeleted";
public static const ON_ROOM_VAR:String = "OnRoomVar";
public var status:Boolean;
public var message:String;
public var statusId:int;
public var userId:int;
public var roomId:int;
public var userName:String;
public var obj:*;
public function SFEvent(param1:String)
{
super(param1);
}
override public function clone() : Event
{
return new SFEvent(type);
}
}
}
@@ -0,0 +1,32 @@
package com.sbi.client
{
public class SFRoom
{
public var name:String;
public var id:int;
public var users:int;
public var maxUsers:int;
public var spectators:int;
public var maxSpectators:int;
public var isPrivate:Boolean;
public var isGame:Boolean;
public var isLimbo:Boolean;
public var isTemp:Boolean;
public function SFRoom()
{
super();
}
}
}