private static void ReceiveCallback(object sender, MessageEventArgs e) { try { if (e.IsText) { Helpers.ConsolePrint("SOCKET", "Received: " + e.Data); dynamic message = JsonConvert.DeserializeObject(e.Data); if (message.method == "sma") { SetAlgorithmRates(message.data); } else if (message.method == "balance") { SetBalance(message.value.Value); } else if (message.method == "versions") { SetVersion(message.legacy.Value); } else if (message.method == "burn") { OnVersionBurn.Emit(null, new SocketEventArgs(message.message.Value)); } } } catch (Exception er) { Helpers.ConsolePrint("SOCKET", er.ToString()); } }
private static void SocketOnOnDataReceived(object sender, MessageEventArgs e) { try { if (e.IsText) { Helpers.ConsolePrint("SOCKET", "Received: " + e.Data); dynamic message = JsonConvert.DeserializeObject(e.Data); switch (message.method.Value) { case "sma": { // Try in case stable is not sent, we still get updated paying rates try { var stable = JsonConvert.DeserializeObject(message.stable.Value); SetStableAlgorithms(stable); } catch { } SetAlgorithmRates(message.data); break; } case "balance": SetBalance(message.value.Value); break; case "versions": SetVersion(message.legacy.Value); break; case "burn": OnVersionBurn.Emit(null, new SocketEventArgs(message.message.Value)); break; case "exchange_rates": SetExchangeRates(message.data.Value); break; } } } catch (Exception er) { Helpers.ConsolePrint("SOCKET", er.ToString()); } }