There sure is, if xmpp reffers XMPPService instnce :-) The source code
follows.
I have made screenshot with Google Talk also:
http://farm4.static.flickr.com/3533/3902870863_a935be9197.jpg

---------------------------------------------
public class ChatBotServlet extends HttpServlet
{
    private static final Logger log = Logger.getLogger
(ChatBotServlet.class.getName());

    private static final String JABBER_ID = "[email protected]";
    private JID myJID = null;


    public void init() throws ServletException
    {
        myJID = new JID(JABBER_ID);
    }

    protected void doPost(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException
    {
        //request.setCharacterEncoding("utf-8");
        XMPPService xmpp = XMPPServiceFactory.getXMPPService();
        Message msg = xmpp.parseMessage(request);

        JID fromJid = msg.getFromJid();
        String body = msg.getBody();

        final String msgBody = "From: "+fromJid+", Text: "+body;
        log.info("xmpp received: " + msgBody);
        final Message outmsg = new MessageBuilder()
                .withRecipientJids(fromJid)
                .withBody(msgBody)
                .build();

        boolean messageSent = false;

        if (xmpp.getPresence(fromJid).isAvailable())
        {
            SendResponse status = xmpp.sendMessage(outmsg);
            messageSent = (status.getStatusMap().get(fromJid) ==
SendResponse.Status.SUCCESS);

        }

        if (!messageSent)
        {
            log.warning("outgoing message hasn't been sent to: " +
fromJid);
        }

    }

    protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException
    {
        //throw new ServletException("doGet is not supported");
    }
}
---------------------------------------------

On Sep 9, 2:37 pm, "Nick Johnson (Google)" <[email protected]>
wrote:
> Hi Artem,
> There is no 'xmpp.parseMessage' method. What method/class are you referring
> to? Can you please paste the code you're using, and the exception (if any)
> you're getting?
>
> -Nick Johnson
>
> On Tue, Sep 8, 2009 at 3:23 PM, Artem Kuroptev <[email protected]> wrote:
>
> > I have created a simple echo xmpp chat bot at [email protected].
> > It works fine for latin characters and I get blank squareы for non-
> > latin. Ihave tried to use
> > request.setCharacterEncoding("utf-8");
> > as a first call at doPost, but that doesn't work.
> > I guess XMPPService.parseMessage method do not takes into account the
> > encoding of POST request. Probably it is possible to parse post
> > request by myself (without XMPPService) and to brute force the
> > character encoding used by requester in Google backed. But if there is
> > a better way?
>
> --
> Nick Johnson, Developer Programs Engineer, App Engine

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google App Engine" 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-appengine?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to