Beispiel #1
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;
                    }

                    sslStream = new SslStream(client.GetStream(), false, AcceptAllCertificates);
                    var ar    = sslStream.BeginAuthenticateAsClient(server, null, null);
                    using (ar.AsyncWaitHandle)
                    {
                        if (ar.AsyncWaitHandle.WaitOne(-1))
                        {
                            sslStream.EndAuthenticateAsClient(ar);
                        }
                    }

                    if (!Handshake())
                    {
                        return;
                    }

                    BeginReceive();

                    if (!SendConnect())
                    {
                        return;
                    }

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

                t.Start();
            }
        }
        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;

                    sslStream = new SslStream(client.GetStream(), false, AcceptAllCertificates);
                    var ar = sslStream.BeginAuthenticateAsClient(server, null, null);
                    using (ar.AsyncWaitHandle)
                    {
                        if (ar.AsyncWaitHandle.WaitOne(-1))
                        {
                            sslStream.EndAuthenticateAsClient(ar);
                        }
                    }

                    if (!Handshake())
                        return;

                    BeginReceive();

                    if (!SendConnect())
                        return;

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

                t.Start();
            }
        }