# onXmppEvent method

1. @override

Future <void> onXmppEvent(

1. XmppEvent event

)
override

Called when XmppConnection triggers an event

## Implementation

    @override
    Future<void> onXmppEvent(XmppEvent event) async {
      if (event is PubSubNotificationEvent) {
        if (event.item.node != userAvatarMetadataXmlns) return;

        if (event.item.payload.tag != 'metadata' ||
            event.item.payload.attributes['xmlns'] != userAvatarMetadataXmlns) {
          logger.warning(
            'Received avatar update from ${event.from} but the payload is invalid. Ignoring...',
          );
          return;
        }

        getAttributes().sendEvent(
          UserAvatarUpdatedEvent(
            JID.fromString(event.from),
            event.item.payload
                .findTags('metadata', xmlns: userAvatarMetadataXmlns)
                .map(UserAvatarMetadata.fromXML)
                .toList(),
          ),
        );
      }
    }