private static void Publish(RapidsConnection rapidsConnection) { while (true) { var jsonMessage = NeedPacket(); Console.WriteLine(" [<] {0}", jsonMessage); rapidsConnection.Publish(jsonMessage); System.Threading.Thread.Sleep(5000); } }
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()); }