Added full chain of P&L notifications

This commit is contained in:
Falkvinge
2017-05-16 08:13:16 +02:00
parent c61bff3866
commit cc40100824
7 changed files with 204 additions and 18 deletions
+25
View File
@@ -5,10 +5,12 @@ using System.Net;
using System.Threading;
using Mono.Unix;
using Mono.Unix.Native;
using NBitcoin.Protocol.Behaviors;
using Newtonsoft.Json.Linq;
using Swarmops.Backend.SocketServices;
using Swarmops.Common.ExtensionMethods;
using Swarmops.Database;
using Swarmops.Logic;
using Swarmops.Logic.Communications;
using Swarmops.Logic.Communications.Payload;
using Swarmops.Logic.Communications.Resolution;
@@ -875,6 +877,29 @@ namespace Swarmops.Backend
}
public static void ProcessMetapackage(SocketMessage message)
{
switch (message.MessageType)
{
case "ProfitLossChanged":
// Broadcast message to recalculate P&L
JObject downstream = new JObject();
downstream["MessageType"] = "RecalculateOrganizationProfitLoss";
downstream["OrganizationId"] = message.OrganizationId.ToString(CultureInfo.InvariantCulture);
Broadcast(downstream);
break;
default:
// Unhandled. Exception?
break;
}
}
private static void Broadcast(JObject json)
{
_socketServer.WebSocketServices.Broadcast(json.ToString());
}
// ------------------------------- BLOCKCHAIN.INFO WEB SOCKET INTERFACE CODE -------------------------
public static void OnBlockchainOpen(object sender, EventArgs args)