Esempio n. 1
0
        private void OnLogout(object sender, LogoutEventArgs e)
        {
            var connectTime = e.LogoutTime - User.LastLogin.Value;

            Console.WriteLine($"User {e.User.Username} logged out, connect time: {connectTime.ToString(@"hh\:mm\:ss")}");

            // Save logout date and total time played this session
            e.User.LastLogout     = e.LogoutTime;
            e.User.SecondsPlayed += (int)connectTime.TotalSeconds;
            Server.UnitOfWork.Users.Update(e.User);
            Server.UnitOfWork.SaveChanges();

            // Dispose timers only relevant when connected
            pingTimer.Dispose();
            connectTimer.Dispose();
        }