Example #1
0
        /// <summary>
        /// Initializes the static <see cref="L"/> class and launches a thread for logging.
        /// Returns a <see cref="Action"/> that will abort the logging thread for use during shutdown.
        /// <para>
        /// WARNING! <see cref="Init(string)"/> is protected by <see cref="SetOnceObject{TStorage}"/>.
        /// If you try to call this method after the initialization has been completed, you are going to receive a <see cref="InvalidOperationException"/>
        /// </para>
        /// </summary>
        /// <param name="logfileName">Logfile</param>
        public static Action Init(string logfileName)
        {
            Logfile.Set(logfileName);
            var t = ServerFrameWork.ST("LogMan", LoggingThread);

            return(() => { t.Abort(); t.Join(); });
        }
Example #2
0
 /// <summary>
 /// Update the information about a given user.
 /// Runs on a different thread and therefor returns instantly
 /// </summary>
 /// <param name="u">User to update</param>
 public void UpdateUser(User u) => ServerFrameWork.QUWI("UpdateUser", (o) => {
     var us = o as User;
     WaitforDeadLock();
     users.Update(us);
     TurboMap.Update();
     Scoreboard.Update();
     C.WriteLine($"Updated: {us.Username}");
 }, u);
 /// <summary>
 /// Manually causes the buffers to update
 /// </summary>
 public void Update()
 {
     lock (this) {
         if (IsBusy)
         {
             return;
         }
         IsBusy = true;
     }
     ServerFrameWork.QUWI("SwMa<" + typeof(T).Name + ">::Update", Thread);
 }
Example #4
0
 /// <summary>
 /// Sends a restore Email to a user.
 /// Runs <see langword="async"/> on a different thread, so this method exits instantly
 /// </summary>
 /// <param name="email">Email of the user to send the restore to</param>
 /// <param name="parent">Calling <see cref="IServer"/>(used for acquiring the URL)</param>
 public void RestoreAccount(string email, IServer parent) => ServerFrameWork.QUWI("DB::RestoreAccount", () => {
     WaitforDeadLock();
     var u = FindEmail(email);
     if (u == null)
     {
         return;
     }
     var fakeSess = new SessionID(-u.Id, rng)
     {
         DeathOn = DateTime.Now + new TimeSpan(1, 0, 0, 0)
     };
     try {
         Email.SendRestoreKey($"{ServerInfo.CreateURL.ToTStorage()(parent)}EmailValidation?id={u.Id}&valid={fakeSess.SID}", email);
         sids.Insert(fakeSess);
     }
     catch { }
 });
Example #5
0
 /// <summary>
 /// Send the deletion request email.
 /// </summary>
 /// <param name="email">Email of the user to send the verification E-mail to</param>
 /// <param name="parent">Calling <see cref="IServer"/>(used for acquiring the URL)</param>
 public void SndDelteEmail(string email, IServer parent) => ServerFrameWork.QUWI("DB::SndDelteEmail", () => {
     WaitforDeadLock();
     var u = FindEmail(email);
     if (u == null)
     {
         return;
     }
     var fakeSess = new SessionID(-u.Id, rng)
     {
         DeathOn = DateTime.Now + new TimeSpan(1, 0, 0)
     };
     try {
         string gen(string a) => $"{ServerInfo.CreateURL.ToTStorage()(parent)}EmailValidation/Delete?action={a}&id={u.Id}&valid={fakeSess.SID}";
         Email.SendDeleteEmail(gen(a_delete), gen(a_cancel), email);
         sids.Insert(fakeSess);
     }
     catch { }
 });