void HandleTradeCommand(string msg, SteamID sender) { var pendingTrades = PendingTrades.ToList(); foreach (var trade in pendingTrades) { if (trade.Target == sender) { Logger.WriteLine("User already in trade queue, ignoring request..."); return; } } if (pendingTrades.Count != 0) { SteamFriends.SendChatMessage(sender, EChatEntryType.ChatMsg, string.Format("You were added to the trade queue at pos #{0}.", pendingTrades.Count + 1)); } var request = new TradeRequest(); request.Timestamp = DateTime.Now; request.Target = sender; PendingTrades.Enqueue(request); }
void ProcessTradeEvents() { // If we are not running a trade and are not waiting for the response // of a pending trade request, then we should dequeue a new trade. bool hasTrade = CurrentTrade != null || PendingTradeRequest != null; bool hasPendingTrades = PendingTrades.Count > 0; if (!hasTrade && hasPendingTrades) { PendingTradeRequest = PendingTrades.Dequeue(); SteamTrading.RequestTrade(PendingTradeRequest.Target); PendingTradeTimer.Change(PendingTradeTimeout, TimeSpan.FromTicks(-1)); } ProcessCurrentTrade(); }
void ResetPendingTrade() { PendingTradeRequest = null; PendingTradeTimer.Change(Timeout.Infinite, Timeout.Infinite); }