class XMPP::PEPNotifications

Overview

PEPNotifications is a high-level client for XEP-0223 - PEP Notifications.

PEP notifications carry an event payload on a subscribed node. When the subscriber also subscribes to the publisher's presence, the notification is delivered inside the presence stanza (as a extension); otherwise it arrives as a message carrying Stanza::PubSubEvent. This wrapper normalizes both delivery channels into the shared PubSubEvent model.

client.on("message") do |s, p| event = XMPP::PEPNotifications.from_message(p.as(XMPP::Stanza::Message)) end

client.on("presence") do |s, p| event = XMPP::PEPNotifications.from_presence(p.as(XMPP::Stanza::Presence)) end

See: https://xmpp.org/extensions/xep-0223.html

Defined in:

xmpp/pep_notifications.cr

Class Method Summary

Class Method Detail

def self.from_message(message : Stanza::Message) : Stanza::PubSubEvent | Nil #

from_message extracts the pubsub#event payload from a message, or nil.


[View source]
def self.from_presence(presence : Stanza::Presence) : Stanza::PubSubEvent | Nil #

from_presence extracts the pubsub#event payload carried by a presence stanza (XEP-0223 §5), or nil.


[View source]
def self.from_stanza(stanza) : Stanza::PubSubEvent | Nil #

from_stanza accepts either a message or presence stanza and returns its pubsub#event payload, or nil when neither carries one.


[View source]