def process_stanza(self, stanza):
self.fix_in_stanza(stanza)<EOL>to_jid = stanza.to_jid<EOL>if not self.process_all_stanzas and to_jid and (<EOL>to_jid != self.me and to_jid.bare() != self.me.bare()):<EOL><INDENT>return self.route_stanza(stanza)<EOL><DEDENT>try:<EOL><INDENT>if isinstance(stanza, Iq):<EOL><INDENT>if self.process_iq(stanza):<EOL><INDENT>return True<EOL><DEDENT><DEDENT>elif isinstance(stanza, Message):<EOL><INDENT>if self.process_message(stanza):<EOL><INDENT>return True<EOL><DEDENT><DEDENT>elif isinstance(stanza, Presence):<EOL><INDENT>if self.process_presence(stanza):<EOL><INDENT>return True<EOL><DEDENT><DEDENT><DEDENT>except ProtocolError as err:<EOL><INDENT>typ = stanza.stanza_type<EOL>if typ != '<STR_LIT:error>' and (typ != '<STR_LIT:result>'<EOL>or stanza.stanza_type != '<STR_LIT>'):<EOL><INDENT>response = stanza.make_error_response(err.xmpp_name)<EOL>self.send(response)<EOL>err.log_reported()<EOL><DEDENT>else:<EOL><INDENT>err.log_ignored()<EOL><DEDENT>return<EOL><DEDENT>logger.debug("<STR_LIT>" % (stanza.stanza_type,<EOL>stanza.serialize()))<EOL>return False<EOL>
Process stanza received from the stream.

        First "fix" the stanza with `self.fix_in_stanza()`,
        then pass it to `self.route_stanza()` if it is not directed
        to `self.me` and `self.process_all_stanzas` is not True. Otherwise
        stanza is passwd to `self.process_iq()`, `self.process_message()`
        or `self.process_presence()` appropriately.

        :Parameters:
            - `stanza`: the stanza received.

        :returns: `True` when stanza was handled