private static void UnexpectedSuccess(RapidsConnection connection, JObject jsonPacket, PacketProblems warnings) { Assert.Fail("Unexpected success parsing JSON packet. Packet is:\n" + jsonPacket + "\nConclusions from parsing/validation are:\n" + warnings); }
public void ProcessPacket(RapidsConnection connection, JObject jsonPacket, PacketProblems warnings) { Console.WriteLine(" [*] {0}", warnings); var needId = jsonPacket["id"].ToString(); _currentBestSolution[needId] = DetermineBestOffer(needId, jsonPacket); Console.WriteLine( $" [======] current best offer for {needId} is from {_currentBestSolution[needId]["solution"]}"); }
public void ProcessPacket(RapidsConnection connection, JObject jsonPacket, PacketProblems warnings) { var need = jsonPacket.ToObject <NeedClass>(); if (need.Forbidden == "y" && need.Membership == "P") { string newJSON = "{\"need\":\"" + need.Need + "\", \"ID\": \"" + need.ID + "\"," + " \"Forbidden\":\"" + need.Forbidden + "\", \"Value\":\"2500\", \"Probability\":\"0.0\", \"Membership\":\"P\"}"; Console.WriteLine("Solution for Member: {0}", newJSON); rapidsConnection.Publish(newJSON); } }
public void ProcessPacket(RapidsConnection connection, JObject jsonPacket, PacketProblems warnings) { Console.WriteLine(" [*] {0}", warnings); jsonPacket["solution"] = "solution_provider"; if (jsonPacket["level"] != null) { jsonPacket["offer"] = DetermineDiscount(int.Parse(jsonPacket["level"].ToString())); } jsonPacket["price"] = _randomGen.Next(1000, 5000); jsonPacket["frequency"] = Math.Round(_randomGen.NextDouble(), 1); connection.Publish(jsonPacket.ToString()); }
public void ProcessPacket(RapidsConnection connection, JObject jsonPacket, PacketProblems warnings) { Console.WriteLine(" [*] {0}", warnings); var userId = int.Parse(jsonPacket["user_id"].ToString()); if (!NewUsers.Contains(userId)) { return; } Console.WriteLine($" [+] user with id {userId} is new user"); jsonPacket["solution"] = "joining_offer"; connection.Publish(jsonPacket.ToString()); }
public void ProcessPacket(RapidsConnection connection, JObject jsonPacket, PacketProblems warnings) { Console.WriteLine(" [*] {0}", warnings); var userId = int.Parse(jsonPacket["user_id"].ToString()); if (!_users.ContainsKey(userId)) { Console.WriteLine($" [-] user with id {userId} not found"); return; } Console.WriteLine($" [+] user with id {userId} has membership level {_users[userId]}"); jsonPacket["level"] = _users[userId]; connection.Publish(jsonPacket.ToString()); }
private static void UnexpectedFailure(RapidsConnection connection, PacketProblems errors) { Assert.Fail("Unexpected JSON packet problem(s):\n" + errors); }
public void ProcessError(RapidsConnection connection, PacketProblems errors) { _failureDelegate(connection, errors); }
public void ProcessPacket(RapidsConnection connection, JObject jsonPacket, PacketProblems warnings) { _successDelegate(connection, jsonPacket, warnings); }
public void ProcessError(RapidsConnection connection, PacketProblems errors) { Console.WriteLine(" [x] {0}", errors); }
public void ProcessPacket(RapidsConnection connection, JObject jsonPacket, PacketProblems warnings) { Console.WriteLine(" [x] {0}", warnings); }
public void SetUp() { _problems = new PacketProblems(ValidJson); }
public void ProcessError(RapidsConnection connection, PacketProblems errors) { throw new NotImplementedException(); }