private void PushRequestPlayfieldListReply(RequestPlayfieldList requestPlayfieldList) { lock (Program.Ircbot.replyQueuePlayfieldList) { LogUtil.Debug(DebugInfoDetail.ISComm, "RequestPlayfieldList Answer received"); Program.Ircbot.replyQueuePlayfieldList.Enqueue(requestPlayfieldList); } }
private void ProcessChatCommandZoneInfo( IrcClient client, IIrcMessageSource source, IList <IIrcMessageTarget> targets, string command, IList <string> parameters) { if (!this.executingRequestPlayfieldList) { this.executingRequestPlayfieldList = true; int numberOfZoneEnginesConnected = Program.ISCom.ClientCount; List <string> addressList = Program.ISCom.GetZoneEngineIds(); Program.ISCom.BroadCast(new RequestPlayfieldList()); StringBuilder sb = new StringBuilder(); var sourceUser = (IrcUser)source; IList <IIrcMessageTarget> replyTargets = this.GetDefaultReplyTarget(client, sourceUser, targets); DateTime startWait = DateTime.UtcNow; bool timeOut = true; while ((DateTime.UtcNow - startWait < TimeSpan.FromSeconds(10) && timeOut)) { lock (this.replyQueuePlayfieldList) { if (this.replyQueuePlayfieldList.Count == Program.ISCom.ClientCount) { timeOut = false; } } } if (timeOut) { client.LocalUser.SendMessage(replyTargets, "{0}", "Not all ZoneEngines replied."); } client.LocalUser.SendMessage( replyTargets, "{0}", "Number of ZoneEngines connected: " + numberOfZoneEnginesConnected); while (this.replyQueuePlayfieldList.Count > 0) { RequestPlayfieldList r = this.replyQueuePlayfieldList.Dequeue(); client.LocalUser.SendMessage( replyTargets, "{0}: Playfields {1}", r.ZoneEngineAddress, string.Join( ", ", r.PlayfieldIds.Select( x => PlayfieldLoader.PFData[x.Instance].Name.Trim() + " (" + x.Instance + ")") .ToArray())); } this.executingRequestPlayfieldList = false; } }
private void HandleRequestPlayfieldList(RequestPlayfieldList requestPlayfieldList) { // Fill in the data requestPlayfieldList.ZoneEngineAddress = this.TcpEndPoint.Address.ToString(); lock (this.playfields) { requestPlayfieldList.PlayfieldIds.Clear(); foreach (Playfield pf in this.playfields) { requestPlayfieldList.PlayfieldIds.Add(pf.Identity); } } // Now send it back to ChatEngine Program.ISComClient.Send(requestPlayfieldList); }