I solved the problem, using FirstElement() instead of FirstChild().

On Jul 23, 7:05 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm working on a libjingle application, and I've got some problem with
> xml handling.
> I tried to make a XmppTask class which handles message stanzas. I
> found an example 
> here:http://groups.google.com/group/google-talk-open/browse_thread/thread/...
>
> The task works fine until it gets to ProcessStart(). I'm sure that the
> message arrives fine to the host. And I put it in the MessageQueue in
> HandleStanza().
>
> int TextSessionClient::ProcessStart()
> {
>     const XmlElement *stanza = NextStanza();
>     if (stanza == NULL)
>         return STATE_BLOCKED;
>     const XmlChild *child = stanza->FirstChild();
>     if (!child)
>         return STATE_START;
>
>     const XmlElement *body = child->AsElement();
>     if (body != NULL) {
>         std::cout << "received message " << body->BodyText().c_str()
> <<
>             " from " << stanza->Attr(QN_FROM).c_str() << std::endl;
>         XmlElement *result = new XmlElement(QN_MESSAGE);
>         result->AddAttr(QN_FROM, GetClient()->jid().Str());
>         result->AddAttr(QN_TO, stanza->Attr(QN_FROM));
>         result->AddAttr(QN_TYPE, STR_CHAT);
>         // result->AddAttr(QN_ID, stanza->Attr(QN_ID));
>         result->AddElement(new XmlElement(QN_BODY));
>         result->AddText("test reply", 1);
>         SendStanza(result);
>     }
>
>     return STATE_START;
>
> }
>
> So the problem is somewhere here.
>
>     const XmlElement *body = child->AsElement();
>     if (body != NULL) {
>
> Body is always NULL. I don't know how I should read out the content of
> the message.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"google-talk-open" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/google-talk-open?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to