What the XMPP protocol depict ,In fact, it is totally the exchange of the XML datas between the client and server. Using the object-oriented thinking to describe the XML fragments as Jabber packets is the common way. I had read some open source projects about jabber both in C# and Java, The designers think in the same way. So is the structure. They just like carving from the same template.
When the Socket receives data from the sender, it all pushes to the StreamParser. Then,StreamParser parses the data。The method of parsing uses the mind of compiler construction principles,describing the keywords as the enumeration of the tokens. I think it will be faster than comparing strings.
As the process of parsing, the StreamParser will trigger the following four events.
1.streamParser_OnStreamStart
2.streamParser_OnStreamEnd
3.streamParser_OnStreamElement
4.streamParser_OnStreamError