ACR_ServerCommunicator.GameServer.RefreshOnlineStatus C# (CSharp) Method

RefreshOnlineStatus() public method

Re-compute the online status for the server.
public RefreshOnlineStatus ( IALFADatabase Database ) : void
Database IALFADatabase Supplies the database connection to use for /// queries, if required. The active rowset may be consumed.
return void
        public void RefreshOnlineStatus(IALFADatabase Database)
        {
            Database.ACR_SQLQuery(String.Format(
                "SELECT " +
                    "`servers`.`ID` AS server_id " +
                "FROM `servers` " +
                "INNER JOIN `pwdata` ON `pwdata`.`Name` = `servers`.`Name` " +
                "WHERE `servers`.`ID` = {0} " +
                "AND pwdata.`Key` = 'ACR_TIME_SERVERTIME' " +
                "AND pwdata.`Last` >= DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 10 MINUTE) ",
                ServerId
                ));

            if (Database.ACR_SQLFetch())
            {
                Online = true;
                DatabaseOnline = true;
            }
            else
            {
                Online = false;
                DatabaseOnline = false;
            }
        }

Usage Example

        /// <summary>
        /// This function inserts a server into the various server lists and
        /// issues the server load event.
        /// </summary>
        /// <param name="Server">Supplies the server object to insert.
        /// </param>
        /// <param name="Database">Supplies the database connection to use for
        /// queries, if required.  The active rowset may be consumed.</param>
        private void InsertNewServer(GameServer Server, IALFADatabase Database)
        {
            //
            // Mark the server as visited so that if we come in on the main
            // thread during the middle of a server synchronization cycle, we
            // won't immediate offline the server.
            //

            Server.Visited = true;
            Server.RefreshOnlineStatus(Database);

            ServerList.Add(Server);
            OnServerLoaded(Server);
        }