mirror of
https://github.com/burrow-dev/burrow-server.git
synced 2026-11-21 01:37:50 -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
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,374 @@
|
||||
package playerWall
|
||||
{
|
||||
import flash.display.MovieClip;
|
||||
import flash.events.MouseEvent;
|
||||
import flash.events.TimerEvent;
|
||||
import flash.net.SharedObject;
|
||||
import flash.utils.Timer;
|
||||
import gui.DarkenManager;
|
||||
import gui.GuiManager;
|
||||
|
||||
public class PlayerWallManager
|
||||
{
|
||||
|
||||
private static var _guiLayer:DisplayLayer;
|
||||
|
||||
private static var _hudWallBtn:MovieClip;
|
||||
|
||||
private static var _glowTimer:Timer;
|
||||
|
||||
private static var _openWallUpdateTimer:Timer;
|
||||
|
||||
private static var _myPlayerWallClosedTimer:Timer;
|
||||
|
||||
private static var _unreadCount:int;
|
||||
|
||||
private static var _inbox:Array;
|
||||
|
||||
private static var _strangerInbox:Array;
|
||||
|
||||
private static var _myPlayerWall:PlayerWallGui;
|
||||
|
||||
private static var _strangersPlayerWall:PlayerWallGui;
|
||||
|
||||
private static var _isFirstTime:Boolean;
|
||||
|
||||
private static var _statusText:String;
|
||||
|
||||
private static var _currentMessageColor:String;
|
||||
|
||||
private static var _currentMessagePattern:int;
|
||||
|
||||
private static var _privacyId:int;
|
||||
|
||||
private static var _reportedStrangerMessageIds:Array;
|
||||
|
||||
private static var _iconId:int;
|
||||
|
||||
public function PlayerWallManager()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function init(initHudWallBtn:MovieClip) : void
|
||||
{
|
||||
PlayerWallXtCommManager.init();
|
||||
PlayerWallXtCommManager.sendPrivacyGetRequest(gMainFrame.server.userName);
|
||||
_guiLayer = GuiManager.guiLayer;
|
||||
_hudWallBtn = initHudWallBtn;
|
||||
_unreadCount = 0;
|
||||
_isFirstTime = true;
|
||||
_hudWallBtn.newPostCount.visible = false;
|
||||
_hudWallBtn.newPostCount.postCountTxt.text = "";
|
||||
_hudWallBtn.glow.visible = true;
|
||||
_glowTimer = new Timer(5000);
|
||||
_glowTimer.addEventListener(TimerEvent.TIMER,glowTimerHandler,false,0,true);
|
||||
_glowTimer.start();
|
||||
_openWallUpdateTimer = new Timer(15000);
|
||||
_openWallUpdateTimer.addEventListener(TimerEvent.TIMER,onMessageUpdateTimer,false,0,true);
|
||||
_myPlayerWallClosedTimer = new Timer(60000);
|
||||
_myPlayerWallClosedTimer.addEventListener(TimerEvent.TIMER,onMessageUpdateTimer,false,0,true);
|
||||
_myPlayerWallClosedTimer.start();
|
||||
var currSharedObj:SharedObject = GuiManager.sharedObj;
|
||||
if(Boolean(currSharedObj) && Boolean(currSharedObj.data))
|
||||
{
|
||||
_currentMessageColor = currSharedObj.data.msgColor != null ? currSharedObj.data.msgColor : "green";
|
||||
_currentMessagePattern = currSharedObj.data.msgPattern != null ? int(currSharedObj.data.msgPattern) : 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
_currentMessageColor = "green";
|
||||
_currentMessagePattern = 1;
|
||||
}
|
||||
_inbox = [];
|
||||
_reportedStrangerMessageIds = [];
|
||||
_hudWallBtn.addEventListener(MouseEvent.MOUSE_DOWN,playerWallBtnDownHandler,false,0,true);
|
||||
}
|
||||
|
||||
public static function destroy() : void
|
||||
{
|
||||
_openWallUpdateTimer.reset();
|
||||
_openWallUpdateTimer = null;
|
||||
_myPlayerWallClosedTimer.reset();
|
||||
_myPlayerWallClosedTimer = null;
|
||||
}
|
||||
|
||||
public static function openStrangersPlayerWall(ownersUserName:String) : void
|
||||
{
|
||||
if(Boolean(_strangersPlayerWall))
|
||||
{
|
||||
_strangersPlayerWall.destroy();
|
||||
_strangersPlayerWall = null;
|
||||
}
|
||||
_strangersPlayerWall = new PlayerWallGui();
|
||||
_strangerInbox = [];
|
||||
_strangersPlayerWall.init(_strangerInbox,ownersUserName,"",0,_currentMessagePattern,"",_currentMessageColor,1714,1714,onStrangerPlayerWallClose);
|
||||
}
|
||||
|
||||
public static function get isFirstTime() : Boolean
|
||||
{
|
||||
return _isFirstTime;
|
||||
}
|
||||
|
||||
public static function set isFirstTime(value:Boolean) : void
|
||||
{
|
||||
_isFirstTime = value;
|
||||
}
|
||||
|
||||
public static function get privacyId() : int
|
||||
{
|
||||
return _privacyId;
|
||||
}
|
||||
|
||||
public static function set privacyId(value:int) : void
|
||||
{
|
||||
_privacyId = value;
|
||||
}
|
||||
|
||||
public static function get reportedMessageIds() : Array
|
||||
{
|
||||
return _reportedStrangerMessageIds;
|
||||
}
|
||||
|
||||
public static function startMyWallTimer() : void
|
||||
{
|
||||
if(Boolean(_openWallUpdateTimer))
|
||||
{
|
||||
_openWallUpdateTimer.start();
|
||||
}
|
||||
}
|
||||
|
||||
public static function onGetResponse(status:Boolean, paramList:Array, isFromHudTimer:Boolean) : void
|
||||
{
|
||||
if(status)
|
||||
{
|
||||
if(isFromHudTimer)
|
||||
{
|
||||
if(paramList.length > _inbox.length && !isFirstTime)
|
||||
{
|
||||
_unreadCount = paramList.length - _inbox.length;
|
||||
_hudWallBtn.newPostCount.visible = true;
|
||||
_hudWallBtn.newPostCount.postCountTxt.text = _unreadCount;
|
||||
_hudWallBtn.glow.visible = true;
|
||||
_glowTimer.start();
|
||||
}
|
||||
}
|
||||
else if(Boolean(_myPlayerWall))
|
||||
{
|
||||
isFirstTime = false;
|
||||
_inbox = paramList.concat();
|
||||
_myPlayerWall.reloadMessages(_inbox);
|
||||
}
|
||||
else if(Boolean(_strangersPlayerWall))
|
||||
{
|
||||
_strangerInbox = paramList.concat();
|
||||
_strangersPlayerWall.reloadMessages(_strangerInbox);
|
||||
}
|
||||
}
|
||||
else if(!isFromHudTimer)
|
||||
{
|
||||
if(Boolean(_myPlayerWall))
|
||||
{
|
||||
isFirstTime = true;
|
||||
_myPlayerWall.reloadMessages(_inbox);
|
||||
}
|
||||
else if(Boolean(_strangersPlayerWall))
|
||||
{
|
||||
_strangersPlayerWall.reloadMessages(_strangerInbox);
|
||||
}
|
||||
}
|
||||
if(!isFromHudTimer)
|
||||
{
|
||||
_openWallUpdateTimer.start();
|
||||
}
|
||||
else
|
||||
{
|
||||
_myPlayerWallClosedTimer.start();
|
||||
}
|
||||
}
|
||||
|
||||
public static function processMessagePush(msg:PostMessage) : void
|
||||
{
|
||||
if(Boolean(_myPlayerWall))
|
||||
{
|
||||
_inbox.unshift(msg);
|
||||
if(Boolean(_myPlayerWall))
|
||||
{
|
||||
_myPlayerWall.reloadMessages(_inbox);
|
||||
}
|
||||
}
|
||||
else if(Boolean(_strangersPlayerWall))
|
||||
{
|
||||
_strangerInbox.unshift(msg);
|
||||
_strangersPlayerWall.reloadMessages(_strangerInbox);
|
||||
}
|
||||
}
|
||||
|
||||
public static function processMessageUpdate(msgId:String, newMsg:String) : void
|
||||
{
|
||||
var tempMessage:PostMessage = null;
|
||||
var inbox:Array = [];
|
||||
if(Boolean(_myPlayerWall))
|
||||
{
|
||||
inbox = _inbox;
|
||||
}
|
||||
else
|
||||
{
|
||||
inbox = _strangerInbox;
|
||||
}
|
||||
for(var j:int = 0; j < inbox.length; j++)
|
||||
{
|
||||
tempMessage = inbox[j];
|
||||
if(tempMessage != null && tempMessage.msgId == msgId)
|
||||
{
|
||||
tempMessage.message = newMsg;
|
||||
if(Boolean(_myPlayerWall))
|
||||
{
|
||||
_myPlayerWall.reloadMessages(inbox);
|
||||
}
|
||||
else if(Boolean(_strangersPlayerWall))
|
||||
{
|
||||
_strangersPlayerWall.reloadMessages(inbox);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function onAddResponse(msgId:String, postTimeStamp:Number, errorMsgId:int) : void
|
||||
{
|
||||
}
|
||||
|
||||
public static function onStrangerReport(msgId:String) : void
|
||||
{
|
||||
_reportedStrangerMessageIds.push(msgId);
|
||||
if(Boolean(_strangersPlayerWall))
|
||||
{
|
||||
_strangersPlayerWall.reloadMessages(_strangerInbox);
|
||||
}
|
||||
}
|
||||
|
||||
public static function onDeleteResponse(owner:String, msgId:String, status:Boolean) : void
|
||||
{
|
||||
var tempMsgId:String = null;
|
||||
var isMyWall:Boolean = false;
|
||||
var j:int = 0;
|
||||
var inbox:Array = [];
|
||||
DarkenManager.showLoadingSpiral(false);
|
||||
if(status)
|
||||
{
|
||||
isMyWall = owner == gMainFrame.userInfo.myUserName;
|
||||
if(isMyWall)
|
||||
{
|
||||
inbox = _inbox;
|
||||
}
|
||||
else
|
||||
{
|
||||
inbox = _strangerInbox;
|
||||
}
|
||||
for(j = 0; j < inbox.length; j++)
|
||||
{
|
||||
tempMsgId = inbox[j].msgId;
|
||||
if(tempMsgId == msgId)
|
||||
{
|
||||
inbox.splice(j,1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(isMyWall && Boolean(_myPlayerWall))
|
||||
{
|
||||
_myPlayerWall.reloadMessages(inbox);
|
||||
}
|
||||
else if(Boolean(_strangersPlayerWall))
|
||||
{
|
||||
_strangersPlayerWall.reloadMessages(inbox);
|
||||
}
|
||||
}
|
||||
|
||||
public static function onStatusResponse(status:Boolean, userName:String, newStatus:String) : void
|
||||
{
|
||||
if(status && userName == gMainFrame.userInfo.myUserName)
|
||||
{
|
||||
_statusText = newStatus;
|
||||
_iconId = 1714;
|
||||
}
|
||||
}
|
||||
|
||||
public static function onPrivacyResponse(status:Boolean, newPrivacyId:int) : void
|
||||
{
|
||||
if(status && Boolean(_myPlayerWall))
|
||||
{
|
||||
_privacyId = newPrivacyId;
|
||||
}
|
||||
}
|
||||
|
||||
private static function playerWallBtnDownHandler(event:MouseEvent) : void
|
||||
{
|
||||
_myPlayerWallClosedTimer.reset();
|
||||
_hudWallBtn.glow.visible = false;
|
||||
_glowTimer.reset();
|
||||
if(Boolean(_myPlayerWall))
|
||||
{
|
||||
_myPlayerWall.destroy();
|
||||
_myPlayerWall = null;
|
||||
}
|
||||
_myPlayerWall = new PlayerWallGui();
|
||||
_myPlayerWall.init(_inbox,gMainFrame.server.userName,_statusText,_privacyId,_currentMessagePattern,_currentMessageColor,_currentMessageColor,_iconId,_iconId,onMyPlayerWallClose);
|
||||
_hudWallBtn.newPostCount.visible = false;
|
||||
_hudWallBtn.newPostCount.postCountTxt.text = "";
|
||||
_unreadCount = 0;
|
||||
}
|
||||
|
||||
private static function onMyPlayerWallClose() : void
|
||||
{
|
||||
_openWallUpdateTimer.reset();
|
||||
_myPlayerWallClosedTimer.start();
|
||||
_currentMessageColor = _myPlayerWall.myCurrMessageColor;
|
||||
_currentMessagePattern = _myPlayerWall.currMessagePattern;
|
||||
_myPlayerWall.destroy();
|
||||
_myPlayerWall = null;
|
||||
}
|
||||
|
||||
private static function onStrangerPlayerWallClose() : void
|
||||
{
|
||||
_openWallUpdateTimer.reset();
|
||||
_currentMessageColor = _strangersPlayerWall.myCurrMessageColor;
|
||||
_currentMessagePattern = _strangersPlayerWall.currMessagePattern;
|
||||
_strangersPlayerWall.destroy();
|
||||
_strangersPlayerWall = null;
|
||||
}
|
||||
|
||||
private static function glowTimerHandler(event:TimerEvent) : void
|
||||
{
|
||||
_glowTimer.stop();
|
||||
_hudWallBtn.glow.visible = false;
|
||||
}
|
||||
|
||||
private static function onMessageUpdateTimer(event:TimerEvent) : void
|
||||
{
|
||||
var isClosedTimer:Boolean = event.currentTarget == _myPlayerWallClosedTimer;
|
||||
if(isClosedTimer)
|
||||
{
|
||||
_myPlayerWallClosedTimer.reset();
|
||||
}
|
||||
else
|
||||
{
|
||||
_openWallUpdateTimer.reset();
|
||||
}
|
||||
if(isClosedTimer)
|
||||
{
|
||||
PlayerWallXtCommManager.sendPostGetRequest(gMainFrame.userInfo.myUserName,null,true);
|
||||
}
|
||||
else if(Boolean(_strangersPlayerWall))
|
||||
{
|
||||
PlayerWallXtCommManager.sendPostGetRequest(_strangersPlayerWall.owner,null);
|
||||
}
|
||||
else
|
||||
{
|
||||
PlayerWallXtCommManager.sendPostGetRequest(gMainFrame.userInfo.myUserName);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,491 @@
|
||||
package playerWall
|
||||
{
|
||||
import com.sbi.debug.DebugUtility;
|
||||
import com.sbi.popup.SBOkPopup;
|
||||
import flash.events.Event;
|
||||
import flash.events.IOErrorEvent;
|
||||
import flash.events.ProgressEvent;
|
||||
import flash.events.SecurityErrorEvent;
|
||||
import flash.events.TimerEvent;
|
||||
import flash.net.Socket;
|
||||
import flash.utils.Timer;
|
||||
import gui.GuiManager;
|
||||
|
||||
public class PlayerWallXtCommManager
|
||||
{
|
||||
|
||||
private static var _deleteResponseCallback:Function;
|
||||
|
||||
private static var _getResponseCallback:Function;
|
||||
|
||||
private static var _addResponseCallback:Function;
|
||||
|
||||
private static var _setStatusResponseCallback:Function;
|
||||
|
||||
private static var _getStatusResponseCallback:Function;
|
||||
|
||||
private static var _socket:Socket;
|
||||
|
||||
private static var _stringToSend:String;
|
||||
|
||||
private static var _cmd:String;
|
||||
|
||||
private static var _currResponseFunction:Function;
|
||||
|
||||
private static var _numDataItemsToReceive:int;
|
||||
|
||||
private static var _numDataItemsReceived:int;
|
||||
|
||||
private static var _receivedData:String;
|
||||
|
||||
private static var _dataToProcess:Array;
|
||||
|
||||
private static var _setPrivacyResponseCallback:Function;
|
||||
|
||||
private static var _getPrivacyResponseCallback:Function;
|
||||
|
||||
private static var _isFromHudTimer:Boolean;
|
||||
|
||||
private static var _retryTimer:Timer;
|
||||
|
||||
private static var _waitingStringToSend:String;
|
||||
|
||||
private static var _waitingResponseCallback:Function;
|
||||
|
||||
private static var _waitingIsFromHudTimer:Boolean;
|
||||
|
||||
private static var _waitingRequestFunction:Function;
|
||||
|
||||
public function PlayerWallXtCommManager()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function init() : void
|
||||
{
|
||||
_socket = new Socket();
|
||||
_socket.addEventListener(Event.CONNECT,onConnected,false,0,true);
|
||||
_socket.addEventListener(IOErrorEvent.IO_ERROR,onIOError,false,0,true);
|
||||
_socket.addEventListener(SecurityErrorEvent.SECURITY_ERROR,onSecurityError,false,0,true);
|
||||
_socket.addEventListener(ProgressEvent.SOCKET_DATA,onSocketData,false,0,true);
|
||||
_retryTimer = new Timer(50);
|
||||
_retryTimer.addEventListener(TimerEvent.TIMER,onRetryTimer,false,0,true);
|
||||
_numDataItemsToReceive = -1;
|
||||
_dataToProcess = [];
|
||||
}
|
||||
|
||||
public static function isSocketOpen() : Boolean
|
||||
{
|
||||
return _socket.connected;
|
||||
}
|
||||
|
||||
public static function sendPostDeleteRequest(stringToSend:String, responseCallback:Function = null) : void
|
||||
{
|
||||
if(canTryToConnect(sendPostDeleteRequest,stringToSend,responseCallback))
|
||||
{
|
||||
if(responseCallback != null)
|
||||
{
|
||||
_deleteResponseCallback = responseCallback;
|
||||
}
|
||||
_currResponseFunction = deleteResponse;
|
||||
_cmd = "D";
|
||||
_stringToSend = stringToSend;
|
||||
setupConnection();
|
||||
}
|
||||
}
|
||||
|
||||
public static function sendPostGetRequest(userName:String, responseCallback:Function = null, isFromHudTimer:Boolean = false) : void
|
||||
{
|
||||
if(canTryToConnect(sendPostGetRequest,userName,responseCallback,isFromHudTimer))
|
||||
{
|
||||
if(responseCallback != null)
|
||||
{
|
||||
_getResponseCallback = responseCallback;
|
||||
}
|
||||
_cmd = "G";
|
||||
_currResponseFunction = getResponse;
|
||||
_stringToSend = userName;
|
||||
_isFromHudTimer = isFromHudTimer;
|
||||
setupConnection();
|
||||
}
|
||||
}
|
||||
|
||||
public static function sendPostAddRequest(stringToSend:String, responseCallback:Function = null) : void
|
||||
{
|
||||
if(canTryToConnect(sendPostAddRequest,stringToSend,responseCallback))
|
||||
{
|
||||
if(responseCallback != null)
|
||||
{
|
||||
_addResponseCallback = responseCallback;
|
||||
}
|
||||
_cmd = "A";
|
||||
_currResponseFunction = addResponse;
|
||||
_stringToSend = stringToSend;
|
||||
setupConnection();
|
||||
}
|
||||
}
|
||||
|
||||
public static function sendStatusSetRequest(stringToSend:String, responseCallback:Function = null) : void
|
||||
{
|
||||
if(canTryToConnect(sendStatusSetRequest,stringToSend,responseCallback))
|
||||
{
|
||||
if(responseCallback != null)
|
||||
{
|
||||
_setStatusResponseCallback = responseCallback;
|
||||
}
|
||||
_cmd = "SC";
|
||||
_currResponseFunction = setStatusResponse;
|
||||
_stringToSend = stringToSend;
|
||||
setupConnection();
|
||||
}
|
||||
}
|
||||
|
||||
public static function sendStatusGetRequest(stringToSend:String, responseCallback:Function = null) : void
|
||||
{
|
||||
if(canTryToConnect(sendStatusGetRequest,stringToSend,responseCallback))
|
||||
{
|
||||
if(responseCallback != null)
|
||||
{
|
||||
_getStatusResponseCallback = responseCallback;
|
||||
}
|
||||
_cmd = "SG";
|
||||
_currResponseFunction = getStatusResponse;
|
||||
_stringToSend = stringToSend;
|
||||
setupConnection();
|
||||
}
|
||||
}
|
||||
|
||||
public static function sendPrivacyGetRequest(stringToSend:String, responseCallback:Function = null) : void
|
||||
{
|
||||
if(canTryToConnect(sendPrivacyGetRequest,stringToSend,responseCallback))
|
||||
{
|
||||
if(responseCallback != null)
|
||||
{
|
||||
_getPrivacyResponseCallback = responseCallback;
|
||||
}
|
||||
_cmd = "OG";
|
||||
_currResponseFunction = getPrivacyResponse;
|
||||
_stringToSend = stringToSend;
|
||||
setupConnection();
|
||||
}
|
||||
}
|
||||
|
||||
public static function sendPrivacySetRequest(stringToSend:String, responseCallback:Function = null) : void
|
||||
{
|
||||
if(canTryToConnect(sendPrivacySetRequest,stringToSend,responseCallback))
|
||||
{
|
||||
if(responseCallback != null)
|
||||
{
|
||||
_setPrivacyResponseCallback = responseCallback;
|
||||
}
|
||||
_cmd = "OC";
|
||||
_currResponseFunction = setPrivacyResponse;
|
||||
_stringToSend = stringToSend;
|
||||
setupConnection();
|
||||
}
|
||||
}
|
||||
|
||||
private static function deleteResponse(data:String) : void
|
||||
{
|
||||
var splitStringToSend:Array = null;
|
||||
var status:Boolean = data == "1" ? true : false;
|
||||
if(_deleteResponseCallback != null)
|
||||
{
|
||||
splitStringToSend = _stringToSend.split("\n");
|
||||
_deleteResponseCallback(splitStringToSend[0],splitStringToSend[1],status);
|
||||
_deleteResponseCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static function addResponse(data:Array) : void
|
||||
{
|
||||
var splitData:Array = null;
|
||||
if(Boolean(data[1]))
|
||||
{
|
||||
splitData = data[1].split("|");
|
||||
}
|
||||
else
|
||||
{
|
||||
splitData = [];
|
||||
}
|
||||
var status:Boolean = data[0] == "1" ? true : false;
|
||||
var severity:int = -1;
|
||||
if(!status)
|
||||
{
|
||||
if(splitData[0] != null)
|
||||
{
|
||||
severity = int(splitData[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
severity = int(data[0]);
|
||||
}
|
||||
}
|
||||
if(_addResponseCallback != null)
|
||||
{
|
||||
_addResponseCallback(status,splitData[1],Number(splitData[2]),severity);
|
||||
_addResponseCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static function getResponse(data:Array) : void
|
||||
{
|
||||
var singlePost:Array = null;
|
||||
var unreadCount:int = 0;
|
||||
var numSkipped:int = 0;
|
||||
var finalData:Array = [];
|
||||
var status:Boolean = data[0] == "1" ? true : false;
|
||||
for(var i:int = 0; i < data.length; i++)
|
||||
{
|
||||
singlePost = data[i].split("|");
|
||||
if(Boolean(singlePost) && singlePost.length > 1)
|
||||
{
|
||||
finalData.push({
|
||||
"msgId":singlePost[0],
|
||||
"message":singlePost[3],
|
||||
"senderUserName":singlePost[2],
|
||||
"iconId":1714,
|
||||
"patternId":int(singlePost[4]),
|
||||
"color":singlePost[5],
|
||||
"postTime":Number(singlePost[1]),
|
||||
"isBuddy":false
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
numSkipped++;
|
||||
}
|
||||
}
|
||||
PlayerWallManager.onGetResponse(status,finalData,_isFromHudTimer);
|
||||
if(_getResponseCallback != null)
|
||||
{
|
||||
_getResponseCallback(status,finalData);
|
||||
_getResponseCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static function setStatusResponse(data:Array) : void
|
||||
{
|
||||
var status:Boolean = data[0] == "1" ? true : false;
|
||||
var severity:int = -1;
|
||||
var splitString:Array = _stringToSend.split("\n");
|
||||
if(!status)
|
||||
{
|
||||
severity = int(data[0]);
|
||||
}
|
||||
PlayerWallManager.onStatusResponse(status,splitString[0],splitString[1]);
|
||||
if(_setStatusResponseCallback != null)
|
||||
{
|
||||
_setStatusResponseCallback(status,severity);
|
||||
_setStatusResponseCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static function getStatusResponse(data:Array) : void
|
||||
{
|
||||
var currIconId:int = 0;
|
||||
var currColor:String = null;
|
||||
var status:Boolean = data[0] == "1" ? true : false;
|
||||
var newStatusString:String = "";
|
||||
if(data[1] != null)
|
||||
{
|
||||
newStatusString = data[1];
|
||||
currIconId = 1714;
|
||||
currColor = "green";
|
||||
}
|
||||
PlayerWallManager.onStatusResponse(status,_stringToSend,newStatusString);
|
||||
if(_getStatusResponseCallback != null)
|
||||
{
|
||||
_getStatusResponseCallback(status,newStatusString,currIconId,currColor);
|
||||
_getStatusResponseCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static function getPrivacyResponse(data:Array) : void
|
||||
{
|
||||
var status:Boolean = data[0] == "1" ? true : false;
|
||||
var newPrivacyId:int = 0;
|
||||
if(data[1] != null)
|
||||
{
|
||||
newPrivacyId = int(data[1]);
|
||||
}
|
||||
PlayerWallManager.onPrivacyResponse(status,newPrivacyId);
|
||||
if(_getPrivacyResponseCallback != null)
|
||||
{
|
||||
_getPrivacyResponseCallback(status,newPrivacyId);
|
||||
_getPrivacyResponseCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static function setPrivacyResponse(data:Array) : void
|
||||
{
|
||||
var status:Boolean = data[0] == "1" ? true : false;
|
||||
var privacyId:int = int(_stringToSend.split("\n")[1]);
|
||||
PlayerWallManager.onPrivacyResponse(status,privacyId);
|
||||
if(_setPrivacyResponseCallback != null)
|
||||
{
|
||||
_setPrivacyResponseCallback(status,privacyId);
|
||||
_setPrivacyResponseCallback = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static function setupConnection() : void
|
||||
{
|
||||
if(_socket.connected)
|
||||
{
|
||||
new SBOkPopup(GuiManager.guiLayer,"Trying to setup a connection when one is already running. Should not be happening");
|
||||
}
|
||||
else
|
||||
{
|
||||
_socket.connect("playerwall.smartbombinteractive.com",6000);
|
||||
}
|
||||
}
|
||||
|
||||
private static function canTryToConnect(requestFunction:Function, stringToSend:String, responseCallback:Function = null, isFromHudTimer:Boolean = false) : Boolean
|
||||
{
|
||||
if(_socket.connected)
|
||||
{
|
||||
if(_waitingRequestFunction == null)
|
||||
{
|
||||
_waitingRequestFunction = requestFunction;
|
||||
_waitingStringToSend = stringToSend;
|
||||
_waitingResponseCallback = responseCallback;
|
||||
_waitingIsFromHudTimer = isFromHudTimer;
|
||||
_retryTimer.start();
|
||||
}
|
||||
else
|
||||
{
|
||||
new SBOkPopup(GuiManager.guiLayer,"We are setting up a retry but a current retry is already running");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static function onRetryTimer(evt:TimerEvent) : void
|
||||
{
|
||||
_retryTimer.reset();
|
||||
if(_socket.connected)
|
||||
{
|
||||
DebugUtility.debugTrace("Still retrying...",65280);
|
||||
_retryTimer.start();
|
||||
}
|
||||
else
|
||||
{
|
||||
_numDataItemsToReceive = -1;
|
||||
if(_waitingIsFromHudTimer)
|
||||
{
|
||||
_waitingRequestFunction(_waitingStringToSend,_waitingResponseCallback,_waitingIsFromHudTimer);
|
||||
}
|
||||
else
|
||||
{
|
||||
_waitingRequestFunction(_waitingStringToSend,_waitingResponseCallback);
|
||||
}
|
||||
_waitingRequestFunction = null;
|
||||
_waitingStringToSend = "";
|
||||
_waitingResponseCallback = null;
|
||||
_waitingIsFromHudTimer = false;
|
||||
}
|
||||
}
|
||||
|
||||
private static function onConnected(evt:Event) : void
|
||||
{
|
||||
}
|
||||
|
||||
private static function onSocketData(evt:ProgressEvent) : void
|
||||
{
|
||||
var splitData:Array = null;
|
||||
var receivedSplitDataLength:int = 0;
|
||||
var currData:String = null;
|
||||
var newData:String = null;
|
||||
var i:int = 0;
|
||||
while(_socket.bytesAvailable > 0)
|
||||
{
|
||||
currData = _socket.readUTFBytes(_socket.bytesAvailable);
|
||||
_numDataItemsReceived += currData.split("\n").length;
|
||||
if(_numDataItemsToReceive == -1)
|
||||
{
|
||||
_receivedData = currData;
|
||||
}
|
||||
else
|
||||
{
|
||||
_receivedData += currData;
|
||||
}
|
||||
}
|
||||
if(_numDataItemsToReceive == -1 || _numDataItemsReceived >= _numDataItemsToReceive)
|
||||
{
|
||||
splitData = _receivedData.split("\r\n");
|
||||
for(i = 0; i < splitData.length; i++)
|
||||
{
|
||||
newData = splitData[i];
|
||||
if(newData == "SID:")
|
||||
{
|
||||
_socket.writeUTFBytes("C:" + _cmd + "\n");
|
||||
DebugUtility.debugTrace("sending command: C:" + _cmd,65280);
|
||||
_socket.flush();
|
||||
}
|
||||
else if(newData == "*")
|
||||
{
|
||||
_socket.writeUTFBytes(_stringToSend + "\n");
|
||||
DebugUtility.debugTrace("sending string: " + _stringToSend,65280);
|
||||
_socket.flush();
|
||||
}
|
||||
else if(newData.indexOf("Build") != -1)
|
||||
{
|
||||
if(Boolean(gMainFrame.clientInfo.devMode))
|
||||
{
|
||||
_socket.writeUTFBytes("A:" + gMainFrame.userInfo.myUserName + "," + gMainFrame.userInfo.myUserName + "," + gMainFrame.server.serverIp + "\n");
|
||||
DebugUtility.debugTrace("sending command: A:" + gMainFrame.userInfo.myUserName + "," + gMainFrame.userInfo.myUserName + "," + gMainFrame.server.serverIp,65280);
|
||||
}
|
||||
else
|
||||
{
|
||||
_socket.writeUTFBytes("A:" + gMainFrame.clientInfo.authToken + "," + gMainFrame.userInfo.myUserName + "," + gMainFrame.server.serverIp + "\n");
|
||||
DebugUtility.debugTrace("sending command: A:" + gMainFrame.clientInfo.authToken + "," + gMainFrame.userInfo.myUserName + "," + gMainFrame.server.serverIp,65280);
|
||||
}
|
||||
_socket.flush();
|
||||
}
|
||||
else if(!(newData == "\r\n" || newData == ""))
|
||||
{
|
||||
if(!isNaN(Number(newData)) && _numDataItemsToReceive == -1)
|
||||
{
|
||||
DebugUtility.debugTrace("number of items to receive = " + int(newData),65280);
|
||||
_numDataItemsToReceive = int(newData);
|
||||
if(_numDataItemsReceived < _numDataItemsToReceive)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if(newData == "**done**")
|
||||
{
|
||||
DebugUtility.debugTrace("receiving **done**",65280);
|
||||
_socket.close();
|
||||
_numDataItemsToReceive = -1;
|
||||
_numDataItemsReceived = 0;
|
||||
_receivedData = "";
|
||||
_currResponseFunction(_dataToProcess);
|
||||
_dataToProcess = [];
|
||||
}
|
||||
else
|
||||
{
|
||||
_dataToProcess.push(newData);
|
||||
DebugUtility.debugTrace("receiving data pieces: " + newData,65280);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static function onIOError(evt:IOErrorEvent) : void
|
||||
{
|
||||
DebugUtility.debugTrace("IO error",65280);
|
||||
_socket.close();
|
||||
}
|
||||
|
||||
private static function onSecurityError(evt:SecurityErrorEvent) : void
|
||||
{
|
||||
DebugUtility.debugTrace("Security error",65280);
|
||||
_socket.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
package playerWall
|
||||
{
|
||||
public class PostMessage
|
||||
{
|
||||
|
||||
private var _message:String;
|
||||
|
||||
private var _senderUserName:String;
|
||||
|
||||
private var _patternId:int;
|
||||
|
||||
private var _color:String;
|
||||
|
||||
private var _msgId:String;
|
||||
|
||||
private var _postTime:Number;
|
||||
|
||||
private var _isBuddy:Boolean;
|
||||
|
||||
private var _iconId:int;
|
||||
|
||||
public function PostMessage(msgId:String, message:String, senderUserName:String, iconId:int, patternId:int, color:String, postTime:Number, isBuddy:Boolean)
|
||||
{
|
||||
super();
|
||||
this._msgId = msgId;
|
||||
this._message = message;
|
||||
this._senderUserName = senderUserName;
|
||||
this._iconId = iconId;
|
||||
this._patternId = patternId;
|
||||
this._color = color;
|
||||
this._postTime = postTime;
|
||||
this._isBuddy = isBuddy;
|
||||
}
|
||||
|
||||
public function get msgId() : String
|
||||
{
|
||||
return this._msgId;
|
||||
}
|
||||
|
||||
public function get message() : String
|
||||
{
|
||||
return this._message;
|
||||
}
|
||||
|
||||
public function get senderUserName() : String
|
||||
{
|
||||
return this._senderUserName;
|
||||
}
|
||||
|
||||
public function get iconId() : int
|
||||
{
|
||||
return this._iconId;
|
||||
}
|
||||
|
||||
public function get patternId() : int
|
||||
{
|
||||
return this._patternId;
|
||||
}
|
||||
|
||||
public function get color() : String
|
||||
{
|
||||
return this._color;
|
||||
}
|
||||
|
||||
public function get postTime() : Number
|
||||
{
|
||||
return this._postTime;
|
||||
}
|
||||
|
||||
public function get isBuddy() : Boolean
|
||||
{
|
||||
return this._isBuddy;
|
||||
}
|
||||
|
||||
public function set msgId(value:String) : void
|
||||
{
|
||||
this._msgId = value;
|
||||
}
|
||||
|
||||
public function set message(value:String) : void
|
||||
{
|
||||
this._message = value;
|
||||
}
|
||||
|
||||
public function set senderUserName(value:String) : void
|
||||
{
|
||||
this._senderUserName = value;
|
||||
}
|
||||
|
||||
public function set patternId(value:int) : void
|
||||
{
|
||||
this._patternId = value;
|
||||
}
|
||||
|
||||
public function set color(value:String) : void
|
||||
{
|
||||
this._color = value;
|
||||
}
|
||||
|
||||
public function set postTime(value:Number) : void
|
||||
{
|
||||
this._postTime = value;
|
||||
}
|
||||
|
||||
public function set isBuddy(value:Boolean) : void
|
||||
{
|
||||
this._isBuddy = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user