Esempio n. 1
0
        async Task RunAsync()
        {
            await ConnectAsync();

            while (!_stopped)
            {
                var f = await frames.Parse();

                if (f == null) // connection broken
                {
                    break;
                }
                switch (f.Command)
                {
                case "DISCONNECT":
                    await DisconnectAsync();

                    break;
                }
            }
            connection.Close();
        }
Esempio n. 2
0
        public async Task can_parse_connect()
        {
            string input  = @"CONNECT
hello:world

" + '\0';
            var    parser = new FrameReader(new MemoryStream(Encoding.UTF8.GetBytes(input)));
            var    f      = await parser.Parse();

            Assert.IsNotNull(f, "frame");
            Assert.AreEqual("CONNECT", f.Command);
            Assert.AreEqual("world", f.Headers["hello"]);
            Assert.AreEqual(0, f.Body.Length, "Body.Length");
        }