public HuntsHubConnection()
 {
     this.Connection = new HubConnectionBuilder().WithUrl("https://xivhunt.net/SignalR/HuntsHub", delegate(HttpConnectionOptions o)
     {
         o.Cookies = HuntsHubConnection.Login(Program.mem.GetHomeWorldId());
     }).AddNewtonsoftJsonProtocol <IHubConnectionBuilder>().Build();
     this.Connection.Closed += this.Connection_Closed;
 }
        internal async Task <bool> Connect(Window1 w1)
        {
            HuntsHubConnection.< > c__DisplayClass12_0 CS$ < > 8__locals1 = new HuntsHubConnection.< > c__DisplayClass12_0();
            CS$ < > 8__locals1.w1 = w1;
            if (this.Connected)
            {
                await this.Connection.StopAsync(default(CancellationToken)).ConfigureAwait(false);
            }
            this.Connected = false;
            bool result;

            if (this.IsConnecting)
            {
                result = false;
            }
            else
            {
                this.IsConnecting = true;
                while (!this.Connected)
                {
                    int num = 0;
                    try
                    {
                        Dispatcher    dispatcher = CS$ < > 8__locals1.w1.HuntConnectionTextBlock.Dispatcher;
                        Func <string> callback;
                        if ((callback = CS$ < > 8__locals1.< > 9__0) == null)
                        {
                            HuntsHubConnection.< > c__DisplayClass12_0 CS$ < > 8__locals2 = CS$ < > 8__locals1;
                            Func <string> func = () => CS$ < > 8__locals1.w1.HuntConnectionTextBlock.Text = Resources.FormConnecting;
                            CS$ < > 8__locals2.< > 9__0 = func;
                            callback = func;
                        }
                        dispatcher.Invoke <string>(callback);
                        await this.Connection.StartAsync(default(CancellationToken)).ConfigureAwait(false);

                        this.Connected = true;
                    }
                    catch (Exception obj)
                    {
                        num = 1;
                    }
                    object obj;
                    if (num == 1)
                    {
                        Exception e = (Exception)obj;
                        if (e is HttpRequestException && e.Message.Contains("401"))
                        {
                            LogHost.Default.WarnException("Failed to connect.", e);
                            await this.Connection.DisposeAsync();

                            this.Connection.Closed  -= this.Connection_Closed;
                            Settings.Default.Cookies = string.Empty;
                            Settings.Default.Save();
                            this.Connection = new HubConnectionBuilder().WithUrl("https://xivhunt.net/SignalR/HuntsHub", delegate(HttpConnectionOptions o)
                            {
                                o.Cookies = HuntsHubConnection.Login(Program.mem.GetHomeWorldId());
                            }).Build();
                            this.Connection.Closed += this.Connection_Closed;
                            this.IsConnecting       = false;
                            return(true);
                        }
                        HuntsHubConnection.< > c__DisplayClass12_1 CS$ < > 8__locals3 = new HuntsHubConnection.< > c__DisplayClass12_1();
                        CS$ < > 8__locals3.CS$ < > 8__locals1 = CS$ < > 8__locals1;
                        CS$ < > 8__locals3.wtime = 5000;
                        LogHost.Default.InfoException(string.Format(CultureInfo.CurrentCulture, Resources.FormConnectingRetrying, 5), e);
                        while (CS$ < > 8__locals3.wtime > 0)
                        {
                            CS$ < > 8__locals3.CS$ < > 8__locals1.w1.HuntConnectionTextBlock.Dispatcher.Invoke <string>(() => CS$ < > 8__locals3.CS$ < > 8__locals1.w1.HuntConnectionTextBlock.Text = string.Format(CultureInfo.CurrentCulture, Resources.FormConnectingRetrying, CS$ < > 8__locals3.wtime / 1000));
                            await Task.Delay(1000);

                            CS$ < > 8__locals3.wtime -= 1000;
                        }
                        CS$ < > 8__locals3 = null;
                    }
                    obj = null;
                }
                this.IsConnecting = false;
                result            = false;
            }
            return(result);
        }