private static void Receive(ConnectedObject client)
        {
            int bytesRead = 0;

            while (true)
            {
                // Read message from the server
                try
                {
                    bytesRead = client.Socket.Receive(client.Buffer, SocketFlags.None);
                }
                catch (SocketException)
                {
                    Console.WriteLine("Server Closed");
                    client.Close();
                    Thread.CurrentThread.Abort();
                }
                catch (Exception)
                {
                    Thread.CurrentThread.Abort();
                    return;
                }


                // Check message
                if (bytesRead > 0)
                {
                    // Build message as it comes in
                    client.BuildIncomingMessage(bytesRead);

                    // Check if we received the full message
                    if (client.MessageReceived())
                    {
                        // Print message to the console
                        Console.WriteLine("Message Received");

                        // Reset message
                        client.ClearIncomingMessage();
                    }
                }
            }
        }
Exemple #2
0
        private static void Receive(ConnectedObject client, LoginScreen parent)
        {
            int bytesRead = 0;

            while (true)
            {
                // Read message from the server
                try
                {
                    bytesRead = client.Socket.Receive(client.Buffer, SocketFlags.None);
                }
                catch (SocketException)
                {
                    Console.WriteLine("Server Closed");
                    client.Close();
                    Thread.CurrentThread.Abort();
                }
                catch (Exception)
                {
                    Thread.CurrentThread.Abort();
                    return;
                }


                // Check message
                if (bytesRead > 0)
                {
                    // Build message as it comes in
                    client.BuildIncomingMessage(bytesRead);

                    // Check if we received the full message
                    if (client.MessageReceived())
                    {
                        // Print message to the console
                        Console.WriteLine("Message Received");

                        Console.WriteLine(client.getIncommingMessage());

                        string response = client.getIncommingMessage().Replace("<END>", "");

                        if (int.Parse(response.Split(',')[0]) == 1)
                        {
                            parent.SetVisible(true);
                            parent.SetText("This Key Got Banned !");
                            parent.SetColor(System.Drawing.Color.Red);
                        }
                        else if (int.Parse(response.Split(',')[0]) == 2)
                        {
                            parent.SetVisible(true);
                            parent.SetText("Password Wrong !");
                            parent.SetColor(System.Drawing.Color.Red);
                        }
                        else if (int.Parse(response.Split(',')[0]) == 3)
                        {
                            parent.SetVisible(true);
                            parent.SetText("Key Already Online !");
                            parent.SetColor(System.Drawing.Color.Yellow);
                        }
                        else if (int.Parse(response.Split(',')[0]) == 4)
                        {
                            parent.SetVisible(true);
                            parent.SetText("Key Binded Click Login Again !");
                            parent.SetColor(System.Drawing.Color.Lime);
                        }
                        else if (int.Parse(response.Split(',')[0]) == 5)
                        {
                            parent.SetVisible(true);
                            parent.SetText("Key Deleted Because Expired !");
                            parent.SetColor(System.Drawing.Color.Red);
                        }
                        else if (int.Parse(response.Split(',')[0]) == 6)
                        {
                            parent.SetVisible(true);
                            parent.SetText("Your Key Expired !");
                            parent.SetColor(System.Drawing.Color.Red);
                        }
                        else if (int.Parse(response.Split(',')[0]) == 7)
                        {
                            parent.SetVisible(true);
                            parent.SetText("You Can't Use On This PC !");
                            parent.SetColor(System.Drawing.Color.Red);
                        }
                        else if (int.Parse(response.Split(',')[0]) == 8)
                        {
                            parent.SetVisible(true);
                            parent.SetText("You Have Been Banned !");
                            parent.SetColor(System.Drawing.Color.Red);
                        }
                        else if (int.Parse(response.Split(',')[0]) == 9)
                        {
                            string            message1 = "VERSION OUTDATED , PLEASE CLICK OK TO UPDATE OR CANCEL TO SHUTDOWN !";
                            string            title1   = "! BYPASS WARNING !";
                            MessageBoxButtons buttons1 = MessageBoxButtons.OKCancel;
                            DialogResult      result1  = MessageBox.Show(message1, title1, buttons1, MessageBoxIcon.Warning);
                            if (result1 == DialogResult.OK)
                            {
                                updater.DoUpdate();
                            }
                            else if (result1 == DialogResult.Cancel)
                            {
                                Application.Exit();
                            }
                        }
                        else if (int.Parse(response.Split(',')[0]) == 10)
                        {
                            parent.SetVisible(false);
                            parent.SafeHide();

                            using (RegistryKey Key = Registry.CurrentUser.OpenSubKey(@"Techcom", true))
                                if (Key != null)
                                {
                                    string val = (string)Key.GetValue("Name");
                                    if (string.IsNullOrEmpty(val))
                                    {
                                        Key.SetValue("Name", "" + response.Split(',')[1] + "");
                                        Key.Close();
                                    }
                                    else
                                    {
                                        Key.SetValue("Name", "" + response.Split(',')[1] + "");
                                        Key.Close();
                                    }
                                }
                                else
                                {
                                    RegistryKey key;
                                    key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("Techcom");
                                    key.SetValue("Name", "" + response.Split(',')[1] + "");
                                    key.Close();
                                }

                            BypassScreen bypassdialog = new BypassScreen();
                            TimeSpan     timeSpan     = new TimeSpan(DateTime.ParseExact(response.Split(',')[2], "yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture).Ticks);
                            DateTime     nistTime     = DateTime.Now;
                            TimeSpan     timeSpan1    = new TimeSpan(nistTime.Ticks);
                            int          totalDays    = (int)(timeSpan.TotalDays - timeSpan1.TotalDays);
                            int          totalHours   = (int)(timeSpan.TotalHours - timeSpan1.TotalHours);
                            int          totalMinutes = (int)(timeSpan.TotalMinutes - timeSpan1.TotalMinutes);
                            string       str1         = "";
                            string       str2         = "";
                            if (totalDays > 0)
                            {
                                str1 = string.Concat("Expire By Days : ", totalDays, " Days");
                                str2 = string.Concat("", totalDays, " Days");
                            }
                            else if (totalHours > 0)
                            {
                                str1 = string.Concat("Expire By Hours: ", totalHours, " Hours");
                                str2 = string.Concat("", totalHours, " Hours");
                            }
                            else if (totalMinutes > 0)
                            {
                                str1 = string.Concat("Expire By Minutes : ", totalMinutes, " Minutes");
                                str2 = string.Concat("", totalMinutes, " Minutes");
                            }
                            bypassdialog.Show();
                            Control[] ctrls = bypassdialog.Controls.Find("username", false);
                            if (ctrls.Length > 0)
                            {
                                Label lbl = (Label)ctrls[0];
                                lbl.Text += response.Split(',')[1];
                            }
                            Control[] ctrls2 = bypassdialog.Controls.Find("keyindays", false);
                            if (ctrls2.Length > 0)
                            {
                                Label lbl = (Label)ctrls2[0];
                                lbl.Text = str1;
                            }
                            Control[] ctrls3 = bypassdialog.Controls.Find("keyindate", false);
                            if (ctrls3.Length > 0)
                            {
                                Label lbl = (Label)ctrls3[0];
                                lbl.Text = "Expire By Date : " + response.Split(',')[2] + "";
                            }
                            bypassdialog.Text += str2;
                            parent.SafeHide();
                        }

                        // Reset message
                        client.ClearIncomingMessage();
                    }
                }
            }
        }