예제 #1
0
        /// <summary>
        /// Shutsdown the ClientManager server and socket
        /// </summary>
        public void Shutdown()
        {
            // Stop accepting new connections
            IgnoreNewConnections = true;
            Exiting = true;

            // Discard the poll timer
            PollTimer.Stop();
            PollTimer.Dispose();
            StatusTimer.Stop();
            StatusTimer.Dispose();

            // Disconnected all connected clients
            Console.WriteLine("Disconnecting all users...");
            Parallel.ForEach(Clients.Values, client => client.Disconnect(DisconnectReason.ForcedServerShutdown));
            Parallel.ForEach(Processing.Values, client => client.Disconnect(DisconnectReason.ForcedServerShutdown));

            // Update the database
            try
            {
                // Set everyone's online session to 0
                databaseDriver.Execute("UPDATE profiles SET status=0, sesskey = NULL");
            }
            catch (Exception e)
            {
                LogWriter.Log.WriteException(e);
            }

            // Update Connected Clients in the Database
            Clients.Clear();

            // Tell the base to dispose all free objects
            Dispose();
        }
예제 #2
0
 public void Unhook()
 {
     if (PollTimer != null)
     {
         PollTimer.Stop();
         PollTimer.Dispose();
     }
 }
예제 #3
0
        /// <summary>
        /// Shutsdown the ClientManager server and socket
        /// </summary>
        public void Shutdown()
        {
            // Stop accepting new connections
            base.IgnoreNewConnections = true;
            Exiting = true;

            // Unregister events so we dont get a shit ton of calls
            GpcmClient.OnSuccessfulLogin -= GpcmClient_OnSuccessfulLogin;
            GpcmClient.OnDisconnect      -= GpcmClient_OnDisconnect;

            // Discard the poll timer
            PollTimer.Stop();
            PollTimer.Dispose();
            StatusTimer.Stop();
            StatusTimer.Dispose();

            // Disconnected all connected clients
            Console.WriteLine("Disconnecting all users...");
            Parallel.ForEach(Clients.Values, client => client.Disconnect(DisconnectReason.ForcedServerShutdown));
            Parallel.ForEach(Processing.Values, client => client.Disconnect(DisconnectReason.ForcedServerShutdown));

            // Update the database
            try
            {
                // Set everyone's online session to 0
                using (Database.GamespyDatabase db = new Database.GamespyDatabase())
                    db.Execute("UPDATE player SET online=0");
            }
            catch (Exception e)
            {
                Program.ErrorLog.Write("WARNING: [GpcmServer.Shutdown] Failed to update client database: " + e.Message);
            }

            // Update Connected Clients in the Database
            Clients.Clear();

            // Shutdown the listener socket
            base.ShutdownSocket();

            // Tell the base to dispose all free objects
            base.Dispose();
        }
예제 #4
0
        /// <summary>
        /// Shutsdown the ClientManager server and socket
        /// </summary>
        public void Shutdown()
        {
            // Stop accepting new connections
            IgnoreNewConnections = true;
            Exiting = true;


            // Unregister events so we dont get a shit ton of calls
            GPCMClient.OnSuccessfulLogin -= ClientSuccessfulLogin;
            GPCMClient.OnDisconnect      -= ClientDisconnected;

            // Discard the poll timer
            PollTimer.Stop();
            PollTimer.Dispose();
            StatusTimer.Stop();
            StatusTimer.Dispose();

            // Disconnected all connected clients
            Console.WriteLine("Disconnecting all users...");
            Parallel.ForEach(Clients.Values, client => client.DisconnectByReason(DisconnectReason.ForcedServerShutdown));
            Parallel.ForEach(Processing.Values, client => client.DisconnectByReason(DisconnectReason.ForcedServerShutdown));

            // Update the database
            try
            {
                // Set everyone's online session to 0
                LoginQuery.ResetStatusAndSessionKey();
            }
            catch (Exception e)
            {
                LogWriter.Log.WriteException(e);
            }

            // Update Connected Clients in the Database
            Clients.Clear();

            DB.Dispose();

            // Tell the base to dispose all free objects
            Dispose();
        }
예제 #5
0
 protected override void Dispose(bool disposingManagedResources)
 {
     if (_disposed)
     {
         return;
     }
     _disposed = true;
     if (disposingManagedResources)
     {
     }
     PollTimer?.Stop();
     PollTimer?.Dispose();
     StatusTimer?.Stop();
     StatusTimer?.Dispose();
     // Disconnected all connected clients
     Console.WriteLine("Disconnecting all users...");
     //Parallel.ForEach(LoggedInSession.Values, client => client.DisconnectByReason(DisconnectReason.ForcedServerShutdown));
     //Parallel.ForEach(InLoginSession.Values, client => client.DisconnectByReason(DisconnectReason.ForcedServerShutdown));
     //LoginQuery.ResetAllStatusAndSessionKey();
     LoggedInSession.Clear();
     DB.Dispose();
     base.Dispose(disposingManagedResources);
 }
예제 #6
0
파일: Battle.cs 프로젝트: thehaunted88/Core
        public void Delete()
        {
            if (Deleted)
            {
                return;
            }

            Reset();

            if (_CoreTimer != null)
            {
                _CoreTimer.Dispose();
                _CoreTimer = null;
            }

            _CoreTicks = 0;

            if (Gate != null)
            {
                Gate.Delete();
                Gate = null;
            }

            ForEachTeam(t => t.Delete());

            if (Schedule != null)
            {
                Schedule.Stop();
                Schedule.Enabled       = false;
                Schedule.OnGlobalTick -= OnScheduleTick;
                Schedule = null;
            }

            if (_BattleRegion != null)
            {
                _BattleRegion.ClearPreview();
                _BattleRegion.Unregister();
                _BattleRegion = null;
            }

            if (_SpectateRegion != null)
            {
                _SpectateRegion.ClearPreview();
                _SpectateRegion.Unregister();
                _SpectateRegion = null;
            }

            if (Options != null)
            {
                Options.Clear();
            }

            OnDeleted();

            if (AutoPvP.RemoveBattle(this))
            {
                OnRemoved();
            }

            Deleted = true;
        }
예제 #7
0
파일: Battle.cs 프로젝트: AllanNisbet/runuo
        public void Delete()
        {
            if (Deleted)
            {
                return;
            }

            Reset();

            EventSink.Shutdown -= ServerShutdownHandler;
            EventSink.Logout   -= LogoutHandler;
            EventSink.Login    -= LoginHandler;

            if (_CoreTimer != null)
            {
                _CoreTimer.Dispose();
                _CoreTimer = null;
            }

            _CoreTicks = 0;

            if (Gate != null)
            {
                Gate.Delete();
                Gate = null;
            }

            Teams.Where(t => t != null && !t.Deleted).ForEach(t => t.Delete());

            if (Schedule != null)
            {
                Schedule.Stop();
                Schedule.Enabled       = false;
                Schedule.OnGlobalTick -= OnScheduleTick;
                Schedule = null;
            }

            if (_BattleRegion != null)
            {
                _BattleRegion.ClearPreview();
                _BattleRegion.Unregister();
                _BattleRegion = null;
            }

            if (_SpectateRegion != null)
            {
                _SpectateRegion.ClearPreview();
                _SpectateRegion.Unregister();
                _SpectateRegion = null;
            }

            if (_Options != null)
            {
                _Options.Clear();
            }

            OnDeleted();

            if (AutoPvP.RemoveBattle(this))
            {
                OnRemoved();
            }

            Deleted = true;
        }