Ejemplo n.º 1
0
        public override ParseResult ContinuePopulate(byte a_byte)
        {
            switch (m_state)
            {
            case State.Done:
                m_state = State.Failed;
                return(ParseResult.Failed);

            case State.WaitForOpenReponse:
                switch (m_actMessage.ContinuePopulate(a_byte))
                {
                case ParseResult.MoreBytesNeeded:
                    return(ParseResult.MoreBytesNeeded);

                case ParseResult.Done:
                    m_messages.Add(m_actMessage.EndPopulate() as SmlMessage);
                    if (m_actMessage.MessageType != SmlMessageType.OpenResponse ||
                        (null == (m_openResponse = m_actMessage.MessageBody as SmlOpenResponse)))
                    {
                        m_state = State.Failed;
                        return(ParseResult.Failed);
                    }
                    m_encoding = m_openResponse.Encoding;

                    m_actMessage = new SmlMessage(m_encoding);
                    switch (m_actMessage.BeginPopulate())
                    {
                    case ParseResult.MoreBytesNeeded:
                        m_state = State.WaitForNextMessage;
                        return(ParseResult.MoreBytesNeeded);

                    default:
                        m_state = State.Failed;
                        return(ParseResult.Failed);
                    }

                default:
                    m_state = State.Failed;
                    return(ParseResult.Failed);
                }

            case State.WaitForNextMessage:
                switch (m_actMessage.ContinuePopulate(a_byte))
                {
                case ParseResult.MoreBytesNeeded:
                    return(ParseResult.MoreBytesNeeded);

                case ParseResult.Done:
                    m_messages.Add(m_actMessage.EndPopulate() as SmlMessage);
                    if (m_actMessage.MessageType == SmlMessageType.CloseResponse)
                    {
                        m_state = State.Done;
                        return(ParseResult.Done);
                    }

                    m_actMessage = new SmlMessage();
                    switch (m_actMessage.BeginPopulate())
                    {
                    case ParseResult.MoreBytesNeeded:
                        m_state = State.WaitForNextMessage;
                        return(ParseResult.MoreBytesNeeded);

                    default:
                        m_state = State.Failed;
                        return(ParseResult.Failed);
                    }

                default:
                    m_state = State.Failed;
                    return(ParseResult.Failed);
                }


            default:
                return(ParseResult.Failed);
            }
        }
Ejemplo n.º 2
0
 public override ParseResult BeginPopulate()
 {
     m_state      = State.WaitForOpenReponse;
     m_actMessage = new SmlMessage();
     return(m_actMessage.BeginPopulate());
 }