/// <summary> /// Setup all the listeners for the database tables /// </summary> public static void SetupDatabaseListeners(OnChange_Player player, OnChange_ResourceOffers resourceOffer, OnChange_TradeOffers tradeOffer, OnChange_Chat chat) { DependencyInitialization(); MonitorPlayers(player); MonitorResourceOffers(resourceOffer); MonitorTradeOffer(tradeOffer); MonitorChat(chat); }
/// <summary> /// Setup listener for the resource offer table /// </summary> /// <param name="resourceOfferMethode"></param> public static void MonitorResourceOffers(OnChange_ResourceOffers resourceOfferMethode) { try { string query = "SELECT Id, HighestBidder, Bid FROM dbo.Market"; monitorConnection = new SqlConnection(connectionString); monitorConnection.Open(); SqlCommand command = new SqlCommand(query, monitorConnection); command.Notification = null; SqlDependency dependency = new SqlDependency(command); dependency.OnChange += new OnChangeEventHandler(resourceOfferMethode); command.ExecuteNonQuery(); } #pragma warning disable CS0168 // Variable is declared but never used catch (SqlException ex) #pragma warning restore CS0168 // Variable is declared but never used { } }