예제 #1
0
        private void SendPacket(RconPacket packet)
        {
            var arr = packet.getBytes();

            stream.Write(arr, 0, arr.Length);
            foreach (byte b in arr)
            {
                Console.Write(b);
            }
            Console.Write('\n');
        }
예제 #2
0
        public void Auth(string password)
        {
            RconPacket auth = new RconPacket(0, PacketType.SERVERDATA_AUTH, password);

            SendPacket(auth);

            /*
             *      if (authresponse.Type == PacketType.SERVERDATA_AUTH_RESPONSE && authresponse.ID != -1)
             *              return true;
             *      else return false;
             */
        }
예제 #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());
     }
 }
예제 #4
0
 private void RconPacketReceived(object client, RconPacket rconPacket)
 {
     if (rconPacket.Type == PacketType.SERVERDATA_AUTH_RESPONSE)
     {
         if (rconPacket.ID != -1)
         {
             textBoxLog.Invoke(textbox3del, new object[] { "Logged in" + Environment.NewLine });
         }
     }
     else if (rconPacket.Type == PacketType.SERVERDATA_RESPONSE_VALUE)
     {
         if (rconPacket.Body.Length > 0)
         {
             textBoxLog.Invoke(textbox3del, new object[] { rconPacket.Body + Environment.NewLine });
         }
     }
 }