Send() static private méthode

static private Send ( UdpClient client, Array message ) : Task
client UdpClient
message Array
Résultat Task
Exemple #1
0
        private static async Task <Dictionary <string, string> > GetRules(UdpClient client)
        {
            byte[] challengeData = await SourceServerQuery.GetChallengeData(client);

            byte[] a2SRULES = challengeData;
            challengeData = null;
            a2SRULES[0]   = SourceServerQuery.A2S_RULES;
            await SourceServerQuery.Send(client, a2SRULES);

            byte[] numArray = await SourceServerQuery.Receive(client);

            byte[] numArray1 = numArray;
            numArray = null;
            Dictionary <string, string> strs = new Dictionary <string, string>();

            using (BinaryReader binaryReader = new BinaryReader(new MemoryStream(numArray1)))
            {
                if (binaryReader.ReadByte() != 69)
                {
                    throw new Exception("Invalid data received in response to A2S_RULES request");
                }
                ushort num = binaryReader.ReadUInt16();
                for (int i = 0; i < num; i++)
                {
                    strs.Add(binaryReader.ReadNullTerminatedUTF8String(SourceServerQuery.readBuffer), binaryReader.ReadNullTerminatedUTF8String(SourceServerQuery.readBuffer));
                }
            }
            binaryReader = null;
            return(strs);
        }
Exemple #2
0
        private static async Task <byte[]> GetChallengeData(UdpClient client)
        {
            await SourceServerQuery.Send(client, SourceServerQuery.A2S_SERVERQUERY_GETCHALLENGE);

            byte[] numArray = await SourceServerQuery.Receive(client);

            byte[] numArray1 = numArray;
            numArray = null;
            if (numArray1[0] != 65)
            {
                throw new Exception("Invalid Challenge");
            }
            return(numArray1);
        }