More Sandbox testing
This commit is contained in:
@@ -11,7 +11,7 @@ namespace Swarmops.Logic.Support
|
||||
{
|
||||
public class ErrorMessages
|
||||
{
|
||||
public static string Localize(string errorMessage, string culture = null)
|
||||
public static string Localized(string errorMessage, string culture = null)
|
||||
{
|
||||
if (String.IsNullOrEmpty(culture))
|
||||
{
|
||||
@@ -21,9 +21,13 @@ namespace Swarmops.Logic.Support
|
||||
}
|
||||
else
|
||||
{
|
||||
return @"<strong>" + Logic_Support_ErrorMessages.ResourceManager.GetString(errorMessage + "_Title", CultureInfo.CreateSpecificCulture(culture)) +
|
||||
return @"<strong>" +
|
||||
Logic_Support_ErrorMessages.ResourceManager.GetString(errorMessage + "_Title",
|
||||
CultureInfo.CreateSpecificCulture(culture)) +
|
||||
@":</strong> " +
|
||||
Logic_Support_ErrorMessages.ResourceManager.GetString(errorMessage + "_Text", CultureInfo.CreateSpecificCulture(culture));
|
||||
Logic_Support_ErrorMessages.ResourceManager.GetString(errorMessage + "_Text",
|
||||
CultureInfo.CreateSpecificCulture(culture));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -773,8 +773,15 @@
|
||||
var _master_bitIdRegisterSuccess = false;
|
||||
|
||||
|
||||
// some localized error messages, used in Swarmops-v5.js (yes, I know it's ugly to split like that, but
|
||||
// Swarmops-v5.js isn't run through the ASPX filter and therefore not localized)
|
||||
|
||||
var _errorDisplay_clientSocketLost = SwarmopsJS.unescape('<%=this.Localized_ClientError_SocketFail%>');
|
||||
var _errorDisplay_clientHeartbeatLost = SwarmopsJS.unescape('<%=this.Localized_ClientError_HeartbeatFail%>');
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
</form>
|
||||
|
||||
<!-- some javascript in footer -->
|
||||
|
||||
@@ -520,6 +520,20 @@ namespace Swarmops.Frontend
|
||||
}
|
||||
|
||||
|
||||
public string Localized_ClientError_SocketFail
|
||||
{
|
||||
get
|
||||
{
|
||||
return
|
||||
CommonV5.JavascriptEscape(
|
||||
ErrorMessages.Localized("Client_ServerConnectionFault"));
|
||||
}
|
||||
}
|
||||
|
||||
public string Localized_ClientError_HeartbeatFail
|
||||
{
|
||||
get { return CommonV5.JavascriptEscape(ErrorMessages.Localized("Client_ServerHeartbeatLost")); }
|
||||
}
|
||||
|
||||
public string GenerateBitIdToken
|
||||
{
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
var _masterSocket;
|
||||
var _masterSocketHeartbeatsLost;
|
||||
var _masterSocketLastHeartbeat;
|
||||
|
||||
|
||||
function _masterInitializeSocket(authenticationTicket) {
|
||||
@@ -15,24 +16,35 @@ function _masterInitializeSocket(authenticationTicket) {
|
||||
_masterSocket = new WebSocket(socketUrl);
|
||||
_masterSocket.onopen = function(data) {
|
||||
if (_masterSocketHeartbeatsLost) {
|
||||
// Reload all edits and the edit pool. If there are discrepancies, we can probably live with them. (Detect editing?)
|
||||
//alertify.log("Backend connection restored without interruption.");
|
||||
|
||||
_masterSocketHeartbeatsLost = false;
|
||||
}
|
||||
if (_error_ClientSocketLost) {
|
||||
_error_ClientSocketLost = false;
|
||||
updateMalfunctions();
|
||||
}
|
||||
|
||||
//watchHeartbeat();
|
||||
};
|
||||
_masterSocket.onclose = function(data) { /* TODO: try reconnecting */ };
|
||||
_masterSocket.onerror = function(data) { alertify.error("WARNING: Socket connection error - realtime updates will not be available"); };
|
||||
_masterSocket.onmessage = function(data) {
|
||||
|
||||
_masterSocket.onclose = function(data) {
|
||||
_error_ClientSocketLost = true;
|
||||
updateMalfunctions();
|
||||
};
|
||||
_masterSocket.onerror = function (data) {
|
||||
if (!_error_ClientSocketLost) {
|
||||
alertify.error("WARNING: Socket connection error - realtime updates will not be available");
|
||||
}
|
||||
};
|
||||
|
||||
_masterSocket.onmessage = function (data) {
|
||||
|
||||
console.log(data.data);
|
||||
|
||||
var message = $.parseJSON(data.data);
|
||||
|
||||
if (message.MessageType == "Heartbeat") {
|
||||
//alertify.log("Master socket heartbeat: " + message.Timestamp);
|
||||
_masterSocketLastHeartbeat = new Date().getTime();
|
||||
|
||||
}
|
||||
else if (message.MessageType == "BitcoinReceived") {
|
||||
// console.log("Currency is " + message.Currency);
|
||||
@@ -44,11 +56,12 @@ function _masterInitializeSocket(authenticationTicket) {
|
||||
}
|
||||
|
||||
if (!handled) {
|
||||
// Otherwise make a log note at the bottom right of the screen
|
||||
alertify.log("Bitcoin received: " + message.Currency + " " + message.CentsFormatted);
|
||||
}
|
||||
}
|
||||
else if (message.MessageType == "Malfunctions") {
|
||||
updateListBox($('#divMalfunctionsList'), message.MalfunctionsList);
|
||||
updateMalfunctions (message.MalfunctionsList);
|
||||
}
|
||||
else if (message.MessageType == "SandboxUpdate") {
|
||||
if (odoLocalParticipation != undefined) { // Real ugly accessing specific page elements here, but it's temporary
|
||||
@@ -70,6 +83,40 @@ function getMasterSocketAddress() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function updateMalfunctions(serverList) {
|
||||
|
||||
if (serverList === undefined) {
|
||||
serverList = _master_LastServerMalfunctionsList;
|
||||
} else {
|
||||
_master_LastServerMalfunctionsList = serverList;
|
||||
}
|
||||
|
||||
var serverArray = Array.from(serverList);
|
||||
if (_masterSocketHeartbeatsLost) {
|
||||
serverArray.push(constructMalfunctionData("ClientHeartbeat", _errorDisplay_clientHeartbeatLost));
|
||||
}
|
||||
if (_error_ClientSocketLost) {
|
||||
serverArray.push(constructMalfunctionData("ClientSocket", _errorDisplay_clientSocketLost));
|
||||
}
|
||||
|
||||
updateListBox($('#divMalfunctionsList'), serverArray);
|
||||
}
|
||||
|
||||
function constructMalfunctionData(id, text, icon, link) {
|
||||
var newItem = {};
|
||||
newItem.Id = id;
|
||||
newItem.Text = text;
|
||||
newItem.Icon = icon;
|
||||
newItem.Link = link;
|
||||
|
||||
return newItem;
|
||||
}
|
||||
|
||||
var _master_LastServerMalfunctionsList = [];
|
||||
var _error_ClientSocketLost = false;
|
||||
|
||||
|
||||
// ------------------- List updating --------------------------
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user