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,174 @@
|
||||
package com.sbi.client
|
||||
{
|
||||
import com.sbi.popup.SBOkPopup;
|
||||
import flash.display.DisplayObject;
|
||||
import flash.display.DisplayObjectContainer;
|
||||
import flash.events.Event;
|
||||
import flash.events.MouseEvent;
|
||||
import flash.events.TimerEvent;
|
||||
import flash.utils.Timer;
|
||||
import localization.LocalizationManager;
|
||||
|
||||
public class KeepAlive
|
||||
{
|
||||
|
||||
private static var KICK_INTERVAL:int = 420000;
|
||||
|
||||
private static var SEND_MSG_INTERVAL:int = 180000;
|
||||
|
||||
private static var NOTIFY_USER_INTERVAL:int = 10000;
|
||||
|
||||
private static var NOTIFY_USER_TIME:int = 30000;
|
||||
|
||||
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;
|
||||
|
||||
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("timer",sendKeepAliveMsg);
|
||||
_timeLeftTimer = new Timer(NOTIFY_USER_INTERVAL);
|
||||
_timeLeftTimer.addEventListener("timer",timeLeftTimer);
|
||||
_timeLeftTimer.start();
|
||||
_lastMsgSentToServer = new Date().getTime();
|
||||
_mcsToKeepAlive = [];
|
||||
_isConnected = param2;
|
||||
_disconnectClient = param3;
|
||||
_playIdleWarningSound = param4;
|
||||
}
|
||||
|
||||
public static function startKATimer(param1:DisplayObjectContainer) : void
|
||||
{
|
||||
param1.addEventListener("mouseDown",inputReceivedHandler,false,0,true);
|
||||
param1.addEventListener("keyDown",inputReceivedHandler,false,0,true);
|
||||
_mcsToKeepAlive.push(param1);
|
||||
_bInputReceived = true;
|
||||
sendKeepAliveMsg(null);
|
||||
_keepAliveTimer.start();
|
||||
}
|
||||
|
||||
public static function stopKATimer(param1:DisplayObjectContainer) : void
|
||||
{
|
||||
var _loc2_:int = 0;
|
||||
gMainFrame.server.setXtObject_Str("ka",[],gMainFrame.server.isWorldZone);
|
||||
_keepAliveTimer.stop();
|
||||
_loc2_ = 0;
|
||||
while(_loc2_ < _mcsToKeepAlive.length)
|
||||
{
|
||||
if(_mcsToKeepAlive[_loc2_] == param1)
|
||||
{
|
||||
_mcsToKeepAlive[_loc2_].removeEventListener("mouseDown",inputReceivedHandler);
|
||||
_mcsToKeepAlive[_loc2_].removeEventListener("keyDown",inputReceivedHandler);
|
||||
_mcsToKeepAlive.splice(_loc2_,1);
|
||||
break;
|
||||
}
|
||||
_loc2_++;
|
||||
}
|
||||
}
|
||||
|
||||
public static function restartTimeLeftTimer() : void
|
||||
{
|
||||
if(_timeLeftTimer)
|
||||
{
|
||||
_lastMsgSentToServer = new Date().getTime();
|
||||
_timeLeftTimer.stop();
|
||||
_timeLeftTimer.start();
|
||||
}
|
||||
}
|
||||
|
||||
public static function sendKeepAliveReset() : void
|
||||
{
|
||||
_bInputReceived = true;
|
||||
sendKeepAliveMsg(null);
|
||||
}
|
||||
|
||||
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 _loc2_:DisplayObject = null;
|
||||
var _loc3_:Number = new Date().getTime() - _lastMsgSentToServer;
|
||||
if(!_kickWarningPopupShowing && _loc3_ > KICK_INTERVAL - NOTIFY_USER_TIME)
|
||||
{
|
||||
_loc2_ = new SBOkPopup(popupLayer,LocalizationManager.translateIdOnly(14681),true,onKickWarningPopup);
|
||||
_kickWarningPopupShowing = true;
|
||||
if(_playIdleWarningSound != null)
|
||||
{
|
||||
_playIdleWarningSound();
|
||||
}
|
||||
if((gMainFrame.userInfo.isModerator || gMainFrame.clientInfo.accountType == 4) && !gMainFrame.server.isBlueboxMode())
|
||||
{
|
||||
_bInputReceived = true;
|
||||
sendKeepAliveMsg(null);
|
||||
_kickWarningPopupShowing = false;
|
||||
SBOkPopup.destroyInParentChain(_loc2_);
|
||||
}
|
||||
}
|
||||
if(_loc3_ > 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,73 @@
|
||||
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_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,34 @@
|
||||
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 var isSubRoom:Boolean;
|
||||
|
||||
public function SFRoom()
|
||||
{
|
||||
super();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user