Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)



The Message Class

The Message class represents an incoming XMPP message.

Message is provided by the google.appengine.api.xmpp module.

  1. Introduction
  2. Message()
  3. Properties:
  4. Instance methods:

Introduction

The Message class constructor takes as an argument a dict-like object with data representing an incoming XMPP message. The keys of the dict must be from , to , and body . For most web application frameworks, the dict can be an object the framework provides that represents form fields parsed from the HTTP POST request initiated by App Engine.

Here is a simple example using the webapp2 framework:

import webapp2
from google.appengine.api import xmpp

class XMPPHandler(webapp2.RequestHandler):
    def post(self):
        message = xmpp.Message(self.request.POST)
        if message.body[0:5].lower() == 'hello':
            message.reply("Greetings!")

app = webapp2.WSGIApplication([('/_ah/xmpp/message/chat/', XMPPHandler)],
                              debug=True)

Constructor

The constructor of the Message class is defined as follows:

class Message ( vars )

An incoming XMPP message.

Arguments

vars

A dict-like object containing the message data, such as an object representing the fields of the POST request for an incoming message. The object must have the following members:

  • from : the XMPP address of the sender
  • to : the XMPP address of the recipient (an address for the application)
  • body : the body content of the XMPP message

Properties

The Message class provides the following read-only properties:

sender

The XMPP address of the sender of the message.

to

The XMPP address of the recipient of the message, an address for the application.

body

The body content of the XMPP message.

command

Provided by google.appengine.ext.webapp.xmpp_handlers : the "command" of the XMPP message.

arg

Provided by google.appengine.ext.webapp.xmpp_handlers : the "command" argument.

Instance Methods

Message instances have the following method:

reply ( body , message_type = MESSAGE_TYPE_CHAT , raw_xml = False )

Reply to this message. This is similar to calling the send_message() function using the Message's sender as the sole recipient of the reply, and the Message's recipient address as the sender.

Arguments

body
The body content of the message.
message_type

The type of the message, one of the types allowed by RFC 3921 . See send_message() for more information.

raw_xml
If True , the body is expected to be valid XML that is included verbatim in the XMPP message stanza. If False , the body is treated as plain text (XML characters are escaped before being inserted into the XMPP message).

Returns a status value. See send_message() for more information on possible status values.

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.