Exemplo n.º 1
0
        public async Task <bool> ProcessData(SocketConnection conn)
        {
            try
            {
                if (conn.CurrentFrame == null)
                {
                    conn.CurrentFrame = FrameFactory.Create(conn.Buffer);

                    if (conn.CurrentFrame == null)
                    {
                        return(true);
                    }
                }

                Frame f = conn.CurrentFrame;
                if (!f.Exam(conn.Buffer))
                {
                    return(true);
                }

                f.Parse(conn.Buffer);
                await f.Process(conn);

                conn.CurrentFrame = null;

                return(true);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                return(false);
            }
        }