Esempio n. 1
0
        private void loginButton_Click(object sender, EventArgs e)
        {
            Match match = ipregex.Match(textBoxIP.Text);

            if (match.Success)
            {
                int port = 27015;
                if (match.Groups[2].Length != 0)
                {
                    port = int.Parse(match.Groups[2].Value);
                    port = port < 65536? port :27015;
                }
                try {
                    client = new RconClient(match.Groups[1].Value, port);
                    client.Auth(textBoxPassword.Text);
                    client.RconPacketReceived += new EventHandler <RconPacket>(RconPacketReceived);
                    client.StartRead();
                    loggedpanel.Visible = true;
                    loginPanel.Visible  = false;
                }
                catch (System.Net.Sockets.SocketException err)
                {
                    MessageBox.Show(err.Message);
                }
            }
        }
Esempio n. 2
0
 private static void ReadSizeCallback(IAsyncResult ar)
 {
     try
     {
         RconClient client = (RconClient)ar.AsyncState;
         client.stream.EndRead(ar);
         int size = BitConverter.ToInt32(client.buff, 0);
         client.stream.BeginRead(client.buff, 4, size, new AsyncCallback(ReadCallback), client);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.ToString());
     }
 }
Esempio n. 3
0
 private static void ReadCallback(IAsyncResult ar)
 {
     try
     {
         RconClient client = (RconClient)ar.AsyncState;
         client.stream.EndRead(ar);
         RconPacket packet = RconPacket.readFromBytes(client.buff);
         client.RconPacketReceived(client, packet);
         Console.WriteLine(packet.Body);
         client.buff = new byte[4096];
         client.stream.BeginRead(client.buff, 0, 4, new AsyncCallback(ReadSizeCallback), client);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.ToString());
     }
 }