xmpp-messaging-core

From DiSo wiki

Jump to: navigation, search

Contents

XMPP Messaging Core

I've started work on an XMPP plugin for Wordpress, a wrapper for the Jabber PHP Client. This plugin will provide an API for other plugins to use XMPP messaging to enable:

Architecture/Design

  • plugin provides XMPP_Client object
    • this object has hooks into every event defined by the jabber api and exposes it (via do_action()) as a wordpress action hook.
    • other plugins can then register callbacks for those hooks via add_action('xmpp_some_event', 'myplugin_event_handler')
  • In another plugin:
 function myplugin_xmpp_authenticated_handler(){
   updateoption('server_authentication_ok', 'Y');
 }
 
 $xmpp = XMPP_Session ($server, $user, $pwd);
 add_action ('xmpp_authenticated', 'myplugin_xmpp_authenticated_handler'); 
 $xmpp->run($run_for_num_seconds);

And the handler will be called when the jabber event for a successful authentication fires.

Issues

Callbacks firing for unintended XMPP sessions

  • Because every callback for a hook is called when the hook fires, the XMPP plugin callbacks are called at the same time (for example) that the WP-Roster callbacks are called. Working on ideas to work around this.
    • One idea is to use different xmpp resources for each connection, and only fire the callbacks if the resource belongs to the providing plugin.
    • SOLUTION: Added support for giving each xmpp object an identifier unique to the plugin that initiated the session. Plugins can determine based on the identifier which callbacks to perform.

Expressing XFN relationships in XMPP

  • Idea: simple add rel="rels" to <presence> and roster <item> elements.
 <presence to='chris.messina@gmail.com' type='subscribe' rel='friend colleague' />
 <item jid='chris.messina@gmail.com' name='Chris' subscription='both' rel='friend colleague' />
  • Upon receiving the subscription request, the recipient's UA should show them the proposed relationship: "User A would like to add you to their roster as a Friend, Colleague" or the like.
    • This is an extension of these stanzas and I have no idea how servers would handle them.
  • Blaine Cooke recommended using the built-in groups feature, which could work but does not allow for notifying the subscribee of the intended relationship...

Workflows

Roster

Update Contacts, Get New Friend Requests

  • connect_and_login()
  • update contacts
    • probably sync with local contacts
  • get friend (xmpp "subscription") requests
  • disconnect

Show user "friend" requests, then

Respond to Friend Requests

  • connect_and_login()
  • send friend responses
  • disconnect

Activity Streams

Get New Activity

  • connect_and_login()
  • get messages
    • pub/sub events
  • disconnect

Update Status

  • connect_and_login()
  • update status (xmpp "presence") (ala facebook status)
  • update activity (ala twitter)
  • disconnect


Links