ACR_ServerCommunicator.GameWorldManager.TransmitOutboundIPCEvents C# (CSharp) Method

TransmitOutboundIPCEvents() private method

This method transmits locally buffered, outboud IPC events to the routing entity (e.g. the database).
private TransmitOutboundIPCEvents ( ) : void
return void
        private void TransmitOutboundIPCEvents()
        {
            IALFADatabase Database = DatabaseLinkQueryThread;
            List<int> ServerIdsToNotify = new List<int>();

            lock (this)
            {
                if (IPCEventQueue.Count == 0)
                    return;

                StringBuilder Query = new StringBuilder(512);

                while (IPCEventQueue.Count != 0)
                {
                    while (Query.Length < TARGET_MAX_QUERY_LENGTH && IPCEventQueue.Count != 0)
                    {
                        IPC_EVENT Event = IPCEventQueue.Dequeue();

                        Query.AppendFormat(
                            "INSERT INTO `server_ipc_events` (`ID`, `SourcePlayerID`, `SourceServerID`, `DestinationPlayerID`, `DestinationServerID`, `EventType`, `EventText`) VALUES (0, {0}, {1}, {2}, {3}, {4}, '{5}');",
                            Event.SourcePlayerId,
                            Event.SourceServerId,
                            Event.DestinationPlayerId,
                            Event.DestinationServerId,
                            Event.EventType,
                            Database.ACR_SQLEncodeSpecialChars(Event.EventText));

                        if (!ServerIdsToNotify.Contains(Event.DestinationServerId))
                            ServerIdsToNotify.Add(Event.DestinationServerId);
                    }

                    Database.ACR_SQLExecute(Query.ToString());
                    Query.Clear();
                }

                //
                // Notify each server that had an entry enqueued that it should
                // wake up to process IPC events.
                //

                foreach (int ServerId in ServerIdsToNotify)
                {
                    GameServer Server = ReferenceServerById(ServerId, null);

                    if (Server != null)
                        ACR_ServerCommunicator.GetNetworkManager().SendMessageIPCWakeup(Server);
                }
            }
        }