Skip to content

Startup sequence

Marc Bauer edited this page Mar 28, 2023 · 2 revisions
sequenceDiagram

participant app as Application
participant core as Core Library
participant cache as Local Cache
participant server as XMPP Server

app ->>+ core: Login
core ->>+ server: Authenticate user
server --)- core: User authenticated
core ->> server: Send initial presence (1)


par Login response
  core --)- app: Login complete
and Configuring session
  par Communicate features
    core ->> server: Send presence with caps hash (2.1.0)
    server -) core: Request features (2.1.1)
    core -->> server: Send features (2.1.2)
    
    loop For each contact
      server --) core: Send contact disco (2.1.3)
      Note right of core: TODO: Request contact features
    end
    
    loop For each contact
      server --) core: Send contact presence (2.1.4)
      core ->> cache: Cache presence into temp table
      core --) app: Send event ContactChanged
    end

    loop For each contact
      server --) core: Send last avatar metadata (2.1.5)
      opt Metadata unknown
        core ->> cache: Cache metadata
        core ->> server: Load image (2.1.6)
        server --) core: Return image (2.1.7)
        core ->> cache: Save image
        core --) app: Send event ContactChanged
      end
    end

    loop For each contact
      server --) core: Send latest vCard (2.1.8)
      opt vCard unknown
        core ->> cache: Cache vCard
        core --) app: Send event ContactChanged
      end
    end
    
  and Configure settings
    core ->> server: Enable carbons (2.2.0)
    server --) core: Send result (2.2.1)
  end
end

app ->>+ core: Load roster

alt Roster cached
  core ->>+ cache: Load roster
  cache -->>- core: Cached roster
  core ->> server: Load roster
else Roster not cached
  core ->>+ server: Load roster
  server --)- core: Roster loaded
end
core --)- app: Roster loaded

opt Roster not cached
server --) core: Roster loaded
end
Loading
  1. Initial presence
<presence/>

2.1.0. Presence with capabilities

<presence><c hash="sha-1" xmlns="http://jabber.org/protocol/caps" ver="lxQNLxOaZh8OBH3ip7SManNtNI8=" node="https://www.prose.org"/></presence>

2.1.1. Feature request

<iq id="disco" to="marc@prose.org/bot_example" type="get" from="marc@prose.org"><query xmlns="http://jabber.org/protocol/disco#info" node="https://www.prose.org#lxQNLxOaZh8OBH3ip7SManNtNI8="/></iq>

2.1.2. Feature response (list of features will grow over time)

<iq id="disco" to="marc@prose.org" type="result">
  <query xmlns="http://jabber.org/protocol/disco#info" node="https://www.prose.org#lxQNLxOaZh8OBH3ip7SManNtNI8=">
    <identity type="pc" category="client" name="Prose" />
    <feature var="urn:xmpp:avatar:data" />
    <feature var="urn:xmpp:avatar:metadata" />
    <feature var="urn:xmpp:avatar:metadata+notify" />
    <feature var="urn:xmpp:ping" />
    <feature var="http://jabber.org/protocol/pubsub" />
    <feature var="http://jabber.org/protocol/pubsub+notify" />
    <feature var="urn:xmpp:receipts" />
    <feature var="urn:ietf:params:xml:ns:vcard-4.0" />
    <feature var="urn:ietf:params:xml:ns:vcard-4.0+notify" />
  </query>
</iq>

2.1.3. Contact disco

<iq id="disco" to="marc@prose.org/bot_example" type="get" from="valerian@prose.org"><query xmlns="http://jabber.org/protocol/disco#info" node="https://www.prose.org#6aWbehzlp0FWzQSHMB9Ma3lEAgo="/></iq>

2.1.4 Contact presence

<presence to="marc@prose.org/bot_example" type="unavailable" from="valerian@prose.org"/>

2.1.5 Send latest avatar metadata

<message to="marc@prose.org/bot_example" type="headline" from="valerian@prose.org">
  <event xmlns="http://jabber.org/protocol/pubsub#event">
    <items node="urn:xmpp:avatar:metadata">
      <item id="bc36d8584dd707cd075947a16d251aad8a873f38">
        <metadata xmlns="urn:xmpp:avatar:metadata">
          <info height="512" id="bc36d8584dd707cd075947a16d251aad8a873f38" bytes="68213" type="public.jpeg" width="512" />
        </metadata>
      </item>
    </items>
  </event>
</message>

2.1.6 Load image

<iq id="0d1196c7-ff58-4611-a264-00403386b71d" to="valerian@prose.org" type="get">
  <pubsub xmlns="http://jabber.org/protocol/pubsub">
    <items node="urn:xmpp:avatar:data">
      <item id="bc36d8584dd707cd075947a16d251aad8a873f38" />
    </items>
  </pubsub>
</iq>

2.1.7 Return image

<iq id="0d1196c7-ff58-4611-a264-00403386b71d" to="marc@prose.org/bot_example" type="result" from="valerian@prose.org">
  <pubsub xmlns="http://jabber.org/protocol/pubsub">
    <items node="urn:xmpp:avatar:data">
      <item id="bc36d8584dd707cd075947a16d251aad8a873f38"><data xmlns="urn:xmpp:avatar:data">/9j/4AAQSkZJRgABAQAASABIAAD...</data></item>
    </items>
  </pubsub>
</iq>

2.1.8 Send latest vCard

<message to="marc@prose.org/bot_example" type="headline" from="marc@prose.org">
  <event xmlns="http://jabber.org/protocol/pubsub#event">
    <items node="urn:ietf:params:xml:ns:vcard-4.0">
      <item id="marc@prose.org">
        <vcard xmlns="urn:ietf:params:xml:ns:vcard-4.0">
          <fn><text>Marc Bauer</text></fn>
          <nickname><text>nesium</text></nickname>
          <org><text>Prose Foundation</text></org>
          <title><text>Apple Platform Developer</text></title>
          <email><text>marc@prose.org</text></email>
          <url>
            <uri>https://www.nesium.com</uri>
          </url>
          <adr>
            <locality>Berlin</locality>
            <country>Germany</country>
          </adr>
        </vcard>
      </item>
    </items>
  </event>
</message>

2.2.0. Enable carbons

<iq id="5d6553cb-803b-4b05-83ea-f4023ef28518" type="set" from="marc@prose.org/bot_example"><enable xmlns="urn:xmpp:carbons:2"/></iq>

2.2.1. Enable carbons result

<iq id="5d6553cb-803b-4b05-83ea-f4023ef28518" to="marc@prose.org/bot_example" type="result"/>
Clone this wiki locally