Receieve() public method

public Receieve ( ) : Task
return Task
Esempio n. 1
0
        public async Task <byte []> Receive(TeleSharp.TL.TLMethod request)
        {
            while (!request.ConfirmReceived)
            {
                var result = DecodeMessage((await _transport.Receieve()).Body);

                using (var messageStream = new MemoryStream(result.Item1, false))
                    using (var messageReader = new BinaryReader(messageStream))
                    {
                        processMessage(result.Item2, result.Item3, messageReader, request);
                    }
            }

            return(null);
        }
Esempio n. 2
0
        private async void StartListening()
        {
            Debug.WriteLine("Start listening");
            finishedListening = new TaskCompletionSource <bool>();
            try
            {
                while (true)
                {
                    var message = await _transport.Receieve().ConfigureAwait(false);

                    if (message == null)
                    {
                        break;
                    }

                    var decodedMessage = DecodeMessage(message.Body);

                    using (var messageStream = new MemoryStream(decodedMessage.Item1, false))
                        using (var messageReader = new BinaryReader(messageStream))
                        {
                            processMessage(decodedMessage.Item2, decodedMessage.Item3, messageReader);
                        }
                }
                finishedListening.SetResult(true);
            }
            catch (ObjectDisposedException ex)
            {
                //disposed
            }
        }
Esempio n. 3
0
        public async Task <byte[]> Receive()
        {
            var result = await _transport.Receieve();

            using (var memoryStream = new MemoryStream(result.Body))
            {
                using (BinaryReader binaryReader = new BinaryReader(memoryStream))
                {
                    long authKeyid     = binaryReader.ReadInt64();
                    long messageId     = binaryReader.ReadInt64();
                    int  messageLength = binaryReader.ReadInt32();

                    byte[] response = binaryReader.ReadBytes(messageLength);

                    return(response);
                }
            }
        }