Пример #1
0
        public void Connect(string user, string password, Region region)

        {
            if (!this.isConnected && HFL_3._0.Rotator.running)
            {
                new Thread(delegate(object state)
                {
                    this.user          = user;
                    this.password      = password;
                    reg                = region;
                    this.regionName    = region.ToString();
                    this.clientVersion = RegionInfo.getRegionVersion(region.ToString());
                    this.server        = RegionInfo.GetServerValue(region);
                    this.loginQueue    = RegionInfo.GetLoginQueueValue(region);
                    this.locale        = RegionInfo.GetLocaleValue(region);
                    this.useGarena     = RegionInfo.GetUseGarenaValue(region);
                    try
                    {
                        this.client = new TcpClient(this.server, 2099);

                        if ((!this.useGarena || this.GetGarenaToken()) && (this.GetAuthKey() && this.GetIpAddress()))
                        {
                            this.sslStream           = new SslStream(this.client.GetStream(), false, new RemoteCertificateValidationCallback(this.AcceptAllCertificates));
                            IAsyncResult asyncResult = this.sslStream.BeginAuthenticateAsClient(this.server, null, null);
                            using (asyncResult.AsyncWaitHandle)
                            {
                                if (asyncResult.AsyncWaitHandle.WaitOne(-1))
                                {
                                    this.sslStream.EndAuthenticateAsClient(asyncResult);
                                }
                            }

                            if (this.Handshake())
                            {
                                this.BeginReceive();
                                if (this.SendConnect() && this.Login())
                                {
                                    this.StartHeartbeat();
                                }
                            }
                        }
                    }
                    catch
                    {
                        this.Error("Riots servers are currently unavailable.", ErrorType.AuthKey);
                        this.Disconnect();
                    }
                }).Start();
            }
        }
Пример #2
0
        public void Connect(string user, string password, Region region, string clientVersion)
        {
            if (!isConnected)
            {
                Thread t = new Thread(() =>
                {
                    this.user = user;
                    this.password = password;
                    this.clientVersion = clientVersion;
                    //this.server = "127.0.0.1";
                    this.server = RegionInfo.GetServerValue(region);
                    this.loginQueue = RegionInfo.GetLoginQueueValue(region);
                    this.locale = RegionInfo.GetLocaleValue(region);
                    this.useGarena = RegionInfo.GetUseGarenaValue(region);

                    //Sets up our sslStream to riots servers
                    try
                    {
                        client = new TcpClient(server, 2099);
                    }
                    catch
                    {
                        Error("Riots servers are currently unavailable.", ErrorType.AuthKey);
                        Disconnect();
                        return;
                    }

                    //Check for riot webserver status
                    //along with gettin out Auth Key that we need for the login process.
                    if (useGarena)
                        if (!GetGarenaToken())
                            return;

                    if (!GetAuthKey())
                        return;

                    if (!GetIpAddress())
                        return;

                    var ar = (IAsyncResult)null;
                    try
                    {
                        sslStream = new SslStream(client.GetStream(), false, AcceptAllCertificates);
                        ar = sslStream.BeginAuthenticateAsClient(server, null, null);
                    }
                    catch (Exception ex)
                    {
                        Disconnect();
                    }

                    using (ar.AsyncWaitHandle)
                    {
                        if (ar.AsyncWaitHandle.WaitOne(-1))
                        {
                            sslStream.EndAuthenticateAsClient(ar);
                        }
                    }

                    if (!Handshake())
                        return;

                    BeginReceive();

                    if (!SendConnect())
                        return;

                    if (!Login())
                        return;
                    StartHeartbeat();
                });

                t.Start();
            }
        }