Exemple #1
0
        public void ReturnServer(Object[] server, Object[] local)
        {
            var dataJson = SerializerAsync.DeserializeJson <Command>(server[0].ToString()).Result;

            try
            {
                if (dataJson != null)
                {
                    if (!dataJson.Cmd.Equals(ServerCommands.Exit))
                    {
                        if (dataJson.Cmd.Equals(ServerCommands.LogResultOk))
                        {
                            ConsoleEx.WriteLine("Uhulll, consegui logar");
                            _expirationTimer =
                                ZZApiMain.SetTimer(
                                    (LoginResultDto.ExpirationDate - LoginResultDto.CreatedDate).TotalMilliseconds,
                                    ExpirationTokenTimer);
                        }
                        else if (dataJson.Cmd.Equals(ServerCommands.LogResultDeny))
                        {
                            ConsoleEx.WriteLine("Algo deu errado");
                            ZZApiMain.RemoveUserConnection(LoginResultDto.Username);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
                throw;
            }
        }
Exemple #2
0
 private void ExpirationTokenTimer(Object source, ElapsedEventArgs e)
 {
     Zz.WriteServer(new Command {
         Cmd = ServerCommands.Logout, Json = SerializerAsync.SerializeJson("Token expired").Result
     });
     ZZApiMain.RemoveUserConnection(LoginResultDto.Username);
 }
        public async Task <ActionResult <bool> > Logout()
        {
            try
            {
                await ZZApiMain.RemoveUserConnection(this.User.Identity.Name);

                return(true);
            }
            catch (Exception e)
            {
                ConsoleEx.WriteError(e);
                return(NotFound());
            }
        }