Ejemplo n.º 1
0
        public Task <Reply> IdentDatenAbrufen(Query query)
        {
            var token  = System.Text.Encoding.UTF8.GetBytes(query.Token);
            var buffer = new byte[4 + 4 + token.Length];

            Array.Copy(BitConverter.GetBytes(Constants.VERSION_1), 0, buffer, 0, 4);
            Array.Copy(BitConverter.GetBytes(token.Length), 0, buffer, 4, 4);
            Array.Copy(token, 0, buffer, 8, token.Length);
            return(_client.RequestResponse(buffer)
                   .ContinueWith(task =>
            {
                var messagecode = BitConverter.ToInt32(task.Result, 0);

                if (messagecode == Constants.REPLY_NOTFOUND)
                {
                    return NotFound.Instance;
                }
                if (messagecode == Constants.REPLY_ERROR)
                {
                    return Parse_ERROR_Datagram(task);
                }
                if (messagecode == Constants.REPLY_RDPINFO)
                {
                    return Parse_RDPINFO_Datagram(task);
                }
                return new InternalError($"Unbekannter MessageCode: {messagecode}!");
            }));
        }