예제 #1
0
        public static object SendAuthData(string serial, string hwid, bool CheckOnly = false)
        {
            FirewallHelper.OpenFirewallPort(port, "ForgeOfBots");
            IPAddress ip     = IPAddress.Parse(IP);
            TcpClient client = new TcpClient();

            try
            {
                client.Connect(ip, port);
                NetworkStream ns     = client.GetStream();
                Thread        thread = new Thread(o => ReceiveData((TcpClient)o, serial, hwid, CheckOnly));
                thread.Start(client);
                byte[] buffer = Encoding.ASCII.GetBytes($"serial:{serial}|hwid:{hwid}|checkOnly:{CheckOnly}");
                ns.Write(buffer, 0, buffer.Length);
                thread.Join();
                while (!done)
                {
                    Application.DoEvents();
                }
                try
                {
                    ns.Close();
                    client.Client.Shutdown(SocketShutdown.Receive);
                    client.Client.Close();
                    client.Close();
                }
                catch (Exception)
                {
                    ns.Dispose();
                    client.Dispose();
                }
                if (ret != null)
                {
                    return(ret);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception)
            {
                return(false);
            }
        }
예제 #2
0
        public static object SendScriptRequest(ScriptRequest eScriptRequest)
        {
            FirewallHelper.OpenFirewallPort(port, "ForgeOfBots");
            IPAddress ip     = IPAddress.Parse(IP);
            TcpClient client = new TcpClient();

            try
            {
                client.Connect(ip, port);
                NetworkStream ns     = client.GetStream();
                Thread        thread = new Thread(o => ReceiveScript((TcpClient)o));
                thread.Start(client);
                byte[] buffer = Encoding.ASCII.GetBytes($"scriptType:{eScriptRequest}");
                ns.Write(buffer, 0, buffer.Length);
                thread.Join();
                while (!done)
                {
                    Application.DoEvents();
                }
                try
                {
                    ns.Close();
                    client.Client.Shutdown(SocketShutdown.Receive);
                    client.Client.Close();
                    client.Close();
                }
                catch (Exception)
                {
                    ns.Dispose();
                    client.Dispose();
                }
                if (ret != null)
                {
                    return(ret);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception)
            {
                return(false);
            }
        }