public void ReportEvents(IndentedTextWriter writer) { writer.WriteLine("This event:"); writer.Indent++; ThisEvent.Report(writer); writer.WriteLine($"{Teams.Count} teams participating"); writer.Indent--; List <Event> otherEvents = OtherEvents; if (otherEvents.Count > 0) { writer.WriteLine(); writer.WriteLine("Previous events:"); bool first = true; writer.Indent++; foreach (var otherEvent in otherEvents) { if (!first) { writer.WriteLine(); } otherEvent.Report(writer); first = false; } writer.Indent--; } writer.WriteLine(); }
public static void TriggerEvent(string eventName, string message) { ThisEvent thisEvent = null; if (instance.eventDictionary.TryGetValue(eventName, out thisEvent)) { thisEvent.Invoke(message); } }
// event trigger with an object passed as a parameter. public static void TriggerEvent(string eventName, string variant) { ThisEvent thisEvent = null; if (Instance.eventDictionary.TryGetValue(eventName, out thisEvent)) { thisEvent.Invoke(variant); } }
// event trigger with a string passed as a parameter. public static void TriggerEvent(string eventName, EventParams eventParams) { ThisEvent thisEvent = null; if (Instance.eventParamDictionary.TryGetValue(eventName, out thisEvent)) { // finally passes the message. thisEvent.Invoke(eventParams); } }
/// <summary> /// Trigger an event with string params. /// </summary> /// <param name="eventName"> Event to trigger.</param> /// <param name="json"> String json params to pass to all the callback actions mapped to this event. </param> public static void TriggerEvent(string eventName, string json) { //print("EventManager:TriggerEvent eventName = " + eventName); ThisEvent thisEvent = null; if (Instance.eventDictionary.TryGetValue(eventName, out thisEvent)) { // Passes the params to all the callbacks waiting on this event. thisEvent.Invoke(json); } }
public static void StopListening(string eventName, UnityAction <string> listener) { if (eventManager == null) { return; } ThisEvent thisEvent = null; if (instance.eventDictionary.TryGetValue(eventName, out thisEvent)) { thisEvent.RemoveListener(listener); } }
public static void StartListening(string eventName, UnityAction <Hashtable> listener) { if (Instance.eventDictionary.TryGetValue(eventName, out ThisEvent thisEvent)) { thisEvent.AddListener(listener); } else { thisEvent = new ThisEvent(); thisEvent.AddListener(listener); Instance.eventDictionary.Add(eventName, thisEvent); } }
/// <summary> /// Receive a Chat Packet from the Client and set it as the TextInput for TextInputWaiters. /// </summary> public void _GetChatPacketBeforeLogin() { #region Receive a Chat Packet from the Client and set it as the TextInput for TextInputWaiters. //Console.WriteLine("NetObject.Client Ready"); while (ClientSocket.Connected) { //Console.WriteLine("NetObject.Client is waiting for data from its Client side socket."); //Console.WriteLine("NetObject.Client Listening..."); Logger.Console.WriteLine("Waiting"); Network.Packet InPacket = Network.Sockets.GetPacket(ClientSocket); Logger.Console.WriteLine("Received"); if (InPacket.Type == 32) { Network.Packets.Type32_ChatMessage ThisPacket = new Network.Packets.Type32_ChatMessage(InPacket); string EditMessage = ThisPacket.Message.Remove(0, 1); EditMessage = EditMessage.Remove(0, Parent.Username.Length); EditMessage = EditMessage.Remove(0, 1); //Console.WriteLine(EditMessage); Parent.TextInput = EditMessage; Logger.Console.WriteLine(Parent.TextInput); foreach (AutoResetEvent ThisEvent in Parent.TextWaiters.ToArray()) { ThisEvent.Set(); Parent.TextWaiters.Remove(ThisEvent); } return; } //Console.WriteLine("NetObject.Client Got Some Data."); if (InPacket.Type != 0) { PreviousPackets.Insert(0, InPacket); while (PreviousPackets.Count > 5) { PreviousPackets.RemoveAt(PreviousPackets.Count - 1); } Logger.Console.WriteLine("!=32"); //ProcessPacket(InPacket); //DONT DO THAT! WE DONT WANT A LOG IN TO HAPPEN ETC. } else { Logger.Console.WriteLine("CLOSE"); //The only time Socket Receive returns 0 is when a remote host disconnects, otherwise, it waits. Parent.Close(); } } Logger.Console.WriteLine("CLOSE2"); #endregion }
public static void StartListening(string eventName, UnityAction <string> listener) { ThisEvent thisEvent = null; if (instance.eventDictionary.TryGetValue(eventName, out thisEvent)) { thisEvent.AddListener(listener); } else { thisEvent = new ThisEvent(); thisEvent.AddListener(listener); instance.eventDictionary.Add(eventName, thisEvent); } }
/// <summary> /// function called to insert an event in the dictionary. /// </summary> /// <param name="eventName"> Event to listen to. </param> /// <param name="listener"> Callback action to be called on event. </param> public static void StartListening(string eventName, UnityAction <string> listener) { //print("EventManager:StartListening eventName = " + eventName); ThisEvent thisEvent = null; if (Instance.eventDictionary.TryGetValue(eventName, out thisEvent)) { thisEvent.AddListener(listener); } else { thisEvent = new ThisEvent(); thisEvent.AddListener(listener); Instance.eventDictionary.Add(eventName, thisEvent); } }
public static void StandardChatMessage(Server.NetObject ThisNetObj, Commands.CommandReader Cmd) { if (ThisNetObj.TextWaiters.Count > 0) { ThisNetObj.TextInput = Cmd._CmdComplete; foreach (AutoResetEvent ThisEvent in ThisNetObj.TextWaiters.ToArray()) { ThisEvent.Set(); ThisNetObj.TextWaiters.RemoveAll(x => x == ThisEvent); } return; } string output = FormatChatMessage(Cmd._CmdComplete, ThisNetObj); Server.AllClients.Except(Database.UserDB.Find("PHP bot")).SendMessage(output); //ThisNetObj.HostObject.SendMessage(output); Logger.Log.Chat(output); return; }
public void LoadDataAccessLayer() { foreach (var row in Tables.LeagueMeets.Rows) { if (row.EventCode.NonNullValue == ThisEventCode) { ThisEvent thisEvent = new ThisEvent(this, row, ThisEventType, ThisEventStatus); EventsByCode[thisEvent.EventCode] = thisEvent; } else { HistoricalLeagueMeet anEvent = new HistoricalLeagueMeet(this, row, TEventType.LEAGUE_MEET, TEventStatus.ARCHIVED); EventsByCode[anEvent.EventCode] = anEvent; } } if (!EventsByCode.ContainsKey(ThisEventCode)) { // *Always* need ThisEvent to be real. Make if we didn't previously encounter. Code path taken only in non-leagues? var row = Tables.LeagueMeets.NewRow(); row.EventCode.Value = ThisEventCode; row.Name.Value = ThisEventName; row.Start.Value = ThisEventNominalStart; row.End.Value = ThisEventNominalEnd; ThisEvent thisEvent = new ThisEvent(this, row, ThisEventType, ThisEventStatus); EventsByCode[thisEvent.EventCode] = thisEvent; } foreach (var row in Tables.Team.Rows) { Team team = new Team(this, row); TeamsByNumber[team.TeamNumber] = team; TeamsById[team.FMSTeamId] = team; Teams.Add(team); } Teams.Sort((a, b) => a.TeamNumber - b.TeamNumber); foreach (var row in Tables.ScheduleDetail.Rows) { if (row.IsEqualizationMatch(this)) { EqualizationMatch equalizationMatch = new EqualizationMatch(this, row); Trace.Assert(equalizationMatch.IsEqualizationMatch); LoadedEqualizationMatches.Add(equalizationMatch); } else { ScheduledMatch scheduledMatch = new ScheduledMatch(this, row); Trace.Assert(!scheduledMatch.IsEqualizationMatch); } } // fmsMatch foreach (var row in Tables.Match.Rows) { MatchPlayedThisEvent matchPlayed = new MatchPlayedThisEvent(this, row); AddOrReplacePlayedMatch(matchPlayed); } // psData foreach (var row in Tables.QualsData.Rows.Concat(Tables.ElimsData.Rows)) { if (PlayedMatchesByNumber.TryGetValue(row.MatchNumber.NonNullValue, out List <MatchPlayedThisEvent> playedMatches)) { foreach (MatchPlayedThisEvent match in playedMatches) { match.Load(row); } } } // psScores foreach (var row in Tables.QualsScores.Rows) { if (PlayedMatchesByNumber.TryGetValue(row.MatchNumber.NonNullValue, out List <MatchPlayedThisEvent> playedMatches)) { foreach (MatchPlayedThisEvent match in playedMatches) { match.Load(row); } } } foreach (var row in Tables.ElimsScores.Rows) { if (PlayedMatchesByNumber.TryGetValue(row.MatchNumber.NonNullValue, out List <MatchPlayedThisEvent> playedMatches)) { foreach (MatchPlayedThisEvent match in playedMatches) { match.Load(row); } } } // psGame foreach (var row in Tables.QualsGameSpecific.Rows.Concat(Tables.ElimsGameSpecific.Rows)) { if (PlayedMatchesByNumber.TryGetValue(row.MatchNumber.NonNullValue, out List <MatchPlayedThisEvent> playedMatches)) { foreach (MatchPlayedThisEvent match in playedMatches) { match.Load(row); } } } // psResult foreach (var row in Tables.QualsResults.Rows.Concat(Tables.ElimsResults.Rows)) { if (PlayedMatchesByNumber.TryGetValue(row.MatchNumber.NonNullValue, out List <MatchPlayedThisEvent> playedMatches)) { foreach (MatchPlayedThisEvent match in playedMatches) { match.Load(row); } } } // psHistory foreach (var row in Tables.QualsCommitHistory.Rows.Concat(Tables.ElimsCommitHistory.Rows)) { if (PlayedMatchesByNumber.TryGetValue(row.MatchNumber.NonNullValue, out List <MatchPlayedThisEvent> playedMatches)) { foreach (MatchPlayedThisEvent match in playedMatches) { match.Load(row); } } } // psScoresHistory foreach (var row in Tables.QualsScoresHistory.Rows) { if (PlayedMatchesByNumber.TryGetValue(row.MatchNumber.NonNullValue, out List <MatchPlayedThisEvent> playedMatches)) { foreach (MatchPlayedThisEvent match in playedMatches) { match.Load(row); } } } foreach (var row in Tables.ElimsScoresHistory.Rows) { if (PlayedMatchesByNumber.TryGetValue(row.MatchNumber.NonNullValue, out List <MatchPlayedThisEvent> playedMatches)) { foreach (MatchPlayedThisEvent match in playedMatches) { match.Load(row); } } } // psGameHistory foreach (var row in Tables.QualsGameSpecificHistory.Rows.Concat(Tables.ElimsGameSpecificHistory.Rows)) { if (PlayedMatchesByNumber.TryGetValue(row.MatchNumber.NonNullValue, out List <MatchPlayedThisEvent> playedMatches)) { foreach (MatchPlayedThisEvent match in playedMatches) { match.Load(row); } } } LeagueSubsystem.Load(); }
public void Raise(object sender, EventInfo info) => ThisEvent?.Invoke(sender, info);